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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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