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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
MayurUshir
Regular Visitor

Calculate and display duration in HH:MM:SS format (09:59:00) in power bi KPI and other chart visual

I have filed with Text Data type (08:30) which is duration (HH:MM)

 

I want to calculate average of that duration and display in duration format, please refer below example:

 

ActualTime Filed :Text Data type (08:30) which is duration (HH:MM)

 

formula:

Average(ActualTime)

 

Display 

(08:30) which is duration (HH:MM)

 

I have alreday use duration data type format and i will get 08:30:00:00 not get converted properly.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @MayurUshir 

I think your HH:MM column is text format. Try this measure.

Avg HH:MM =
VAR _T =
    ADDCOLUMNS ( 'Table', "TimeValue", TIMEVALUE ( 'Table'[HH:MM] ) )
VAR _T2 =
    ADDCOLUMNS ( _T, "HH", HOUR ( [TimeValue] ), "MM", MINUTE ( [TimeValue] ) )
VAR _AllMinutes =
    SUMX ( _T2, [HH] ) * 60
        + SUMX ( _T2, [MM] )
VAR _Count =
    COUNTROWS ( 'Table' )
VAR _AVGMinutes =
    DIVIDE ( _AllMinutes, _Count )
VAR _HH_MM =
    COMBINEVALUES (
        ":",
        FORMAT ( INT ( DIVIDE ( _AVGMinutes, 60 ) ), "0#" ),
        MOD ( _AVGMinutes, 60 )
    )
RETURN
    _HH_MM

My Sample:

1.png

Result is as below.

1.png

Best Regards,
Rico Zhou

 

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
Anonymous
Not applicable

Hi @MayurUshir 

I think your HH:MM column is text format. Try this measure.

Avg HH:MM =
VAR _T =
    ADDCOLUMNS ( 'Table', "TimeValue", TIMEVALUE ( 'Table'[HH:MM] ) )
VAR _T2 =
    ADDCOLUMNS ( _T, "HH", HOUR ( [TimeValue] ), "MM", MINUTE ( [TimeValue] ) )
VAR _AllMinutes =
    SUMX ( _T2, [HH] ) * 60
        + SUMX ( _T2, [MM] )
VAR _Count =
    COUNTROWS ( 'Table' )
VAR _AVGMinutes =
    DIVIDE ( _AllMinutes, _Count )
VAR _HH_MM =
    COMBINEVALUES (
        ":",
        FORMAT ( INT ( DIVIDE ( _AVGMinutes, 60 ) ), "0#" ),
        MOD ( _AVGMinutes, 60 )
    )
RETURN
    _HH_MM

My Sample:

1.png

Result is as below.

1.png

Best Regards,
Rico Zhou

 

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

mahoneypat
Microsoft Employee
Microsoft Employee

Please see this video for best practices on calculating and formatting durations.

(5) It's About Time - Part Two - YouTube

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Greg_Deckler
Community Champion
Community Champion

@MayurUshir You need Chelsie Eiden's Duration: Chelsie Eiden's Duration - Microsoft Power BI Community



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.