Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
ZusakheS
New Member

Duration keeps changing to decimal after load

Why is it that data containing durations changes to a decimal after it is loaded into powerbi even though the data type is defined as duration in the transform stage. Is there a way to avoid this? Is the a measure that I can use?

1 ACCEPTED SOLUTION
v-yueyunzh-msft
Community Support
Community Support

Hi , @ZusakheS 

Based on my understanding and research on this product, currently there's no way to automatically to change the duration of time to the "Durtaion" format because there's no supported column format currently, you may try to create a measure as the workaround to achieve this duration in the time format like this:

 


You can follow these steps to calcualte:

1. Change the data type of duration column to HH:MM:SS:

vyueyunzhmsft_0-1683772371346.png

 

2. Create a calculate column to get the seconds:

Second = SECOND('Table'[Duration])

 

3. Create a measure to calculate the average seconds:

Average =
VAR _avg =
AVERAGE ( 'Table'[Second] )
VAR HoursPart =
MOD ( INT ( _avg / 3600 ), 24 )
VAR MinPart =
MOD ( INT ( _avg / 60 ), 60 )
VAR SecPart =
MOD ( _avg, 60 )
RETURN
FORMAT (
CONVERT ( HoursPart & ":" & MinPart & ":" & SecPart, DATETIME ),
"hh:mm:ss"
)

 

vyueyunzhmsft_1-1683772443997.png

 

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

3 REPLIES 3
weechia__ll
New Member

If i have hour and minute

weechia__ll_0-1701389834066.png

Because Ihave hour and minute, so how to create column and average time??

DAXRichArd
Resolver I
Resolver I

Hi ZusakheS,

I faced the same where in Query I convert duration into Hrs:Minutes:Seconds.

When I load the query, duration is converted to a decimal number.

See my solutions below.

I created two calculated columns to test my measure.

I pull certain columns into a table and review / test the results through manual calculations.

Call duration decimal nu is a simple subtraction that returns a decimal number.

Call duration takes that result and formates it into Hrs:Minutes:Seconds.

-CAUTION: formating it this way results in a string (text). The string will sort as a number if sorting is desired.

The measure is the end product I wanted. I sum the decimal number then format it as Hrs:Minutes:Seconds.

I am still testing however this is my approach.

CALCULATED COLUMNS

Call Duration decimal nu =

    'F - AOC CiscoPhone'[Call End Time] -
    'F - AOC CiscoPhone'[Call Start Time]
Call Duration =
    FORMAT ( 'F - AOC CiscoPhone'[Call Duration decimal nu],
    "HH:NN:SS" )
MEASURE
Cisco Total Call Time =
FORMAT(
    SUM('F - AOC CiscoPhone'[Call Duration decimal nu]) ,
    "HH:NN:SS"
)

DAXRichArd_0-1683817281035.png

v-yueyunzh-msft
Community Support
Community Support

Hi , @ZusakheS 

Based on my understanding and research on this product, currently there's no way to automatically to change the duration of time to the "Durtaion" format because there's no supported column format currently, you may try to create a measure as the workaround to achieve this duration in the time format like this:

 


You can follow these steps to calcualte:

1. Change the data type of duration column to HH:MM:SS:

vyueyunzhmsft_0-1683772371346.png

 

2. Create a calculate column to get the seconds:

Second = SECOND('Table'[Duration])

 

3. Create a measure to calculate the average seconds:

Average =
VAR _avg =
AVERAGE ( 'Table'[Second] )
VAR HoursPart =
MOD ( INT ( _avg / 3600 ), 24 )
VAR MinPart =
MOD ( INT ( _avg / 60 ), 60 )
VAR SecPart =
MOD ( _avg, 60 )
RETURN
FORMAT (
CONVERT ( HoursPart & ":" & MinPart & ":" & SecPart, DATETIME ),
"hh:mm:ss"
)

 

vyueyunzhmsft_1-1683772443997.png

 

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.