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
svelazquez
Regular Visitor

How to get an Average Number based on hh:nn:ss format?

Hi everyone,

 

I am trying to get an Average of one Column with the following formtat: (hh:nn:ss) 

 

When using the SUM calculation, it gives me the right number , however, when I change the calculation to AVERAGE, it changes the result format automatically.

 

My question here is, what can I do to get the AVERAGE of my column with the same format (hh:nn:ss)?

image3.pngimage2.pngimage1.png

 

5 REPLIES 5
v-yangliu-msft
Community Support
Community Support

Hi  @svelazquez ,

Here are the steps you can follow:

1. Enter Power Query, select Date column - Add Column - Time - select Hour / Minute / Second to create three columns respectively..

vyangliumsft_0-1666838712609.png

2. Create calculated column.

seconds =
[Hour]*60*60 + [Minute]*60 + [Second]
Duration Average =
RIGHT (
    "0"
        & INT (
            (
                AVERAGEA ( 'Table'[seconds] )
                    - INT ( AVERAGEA ( 'Table'[seconds] ) / ( 24 * 60 * 60 ) ) * ( 24 * 60 * 60 )
            ) / 3600
        ),
    2
) & ":"
    & RIGHT (
        "0"
            & INT (
                (
                    AVERAGEA ( 'Table'[seconds] )
                        - INT ( AVERAGEA ( 'Table'[seconds] ) / 3600 ) * 3600
                ) / 60
            ),
        2
    ) & ":"
    & RIGHT (
        "0"
            & (
                AVERAGEA ( 'Table'[seconds] )
                    - INT ( AVERAGEA ( 'Table'[seconds] ) / 60 ) * 60
            ),
        2
    )

3. Result:

vyangliumsft_1-1666838712613.png

 

Best Regards,

Liu Yang

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

Hi, thanks for your help. Just one more question, at the time I try to insert the second formula (Duration Avg) it says the expression "RIGHT" is not recognized by the system. 

 

amitchandak
Super User
Super User

@svelazquez , First convert data to an hour to an Average and convert back to a time

 

Measure =

var _hr = AverageX(Table,  hour([Time])+ minute([Time])/60 + second([Time]) )

return

Time(0,0,0) +_hr

please, can you tell me more about how to do this process? I didn't completely understand, sorry

But I first need to create a table right?

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.