Forum Discussion
Average Duration
- 4 years ago
Hi, Anonymous
Power BI does not support duration type. Please try follow steps:
1.Change the data type of duration column to HH:MM:SS and add a calculated column to convert the durtaion to time in secondsTotal_seconds = SECOND('Table'[Duration])+MINUTE('Table'[Duration])*60+HOUR('Table'[Duration])*36002. Create a measure to calculate the average second and reconvert it to duration
Average = VAR _avg=AVERAGE('Table'[Total_seconds]) VAR HoursPart = MOD ( INT ( _avg / 3600 ), 24 ) VAR MinPart = MOD ( INT ( _avg / 60 ), 60 ) VAR SecPart = MOD ( INT ( _avg ), 60 ) RETURN FORMAT ( CONVERT ( HoursPart & ":" & MinPart & ":" & SecPart, DATETIME ), "hh:mm:ss" )Please check my attached sample file for more details.
Best Regards,
Community Support Team _ Eason
Hi, Anonymous
Power BI does not support duration type. Please try follow steps:
1.Change the data type of duration column to HH:MM:SS and add a calculated column to convert the durtaion to time in seconds
Total_seconds = SECOND('Table'[Duration])+MINUTE('Table'[Duration])*60+HOUR('Table'[Duration])*3600
2. Create a measure to calculate the average second and reconvert it to duration
Average =
VAR _avg=AVERAGE('Table'[Total_seconds])
VAR HoursPart =
MOD ( INT ( _avg / 3600 ), 24 )
VAR MinPart =
MOD ( INT ( _avg / 60 ), 60 )
VAR SecPart =
MOD ( INT ( _avg ), 60 )
RETURN
FORMAT (
CONVERT ( HoursPart & ":" & MinPart & ":" & SecPart, DATETIME ),
"hh:mm:ss"
)
Please check my attached sample file for more details.
Best Regards,
Community Support Team _ Eason