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.
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?
Solved! Go to Solution.
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:
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"
)
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
If i have hour and minute
Because Ihave hour and minute, so how to create column and average time??
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 =
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:
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"
)
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
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
101 | |
75 | |
63 | |
62 |
User | Count |
---|---|
141 | |
104 | |
101 | |
80 | |
67 |