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
wilburn
New Member

How to deal with average time duration bucketed by hour

I have 5 APIs (/api/v1/a, /api/v1/b, etc.).

 

Each hour, I get the average time it takes for requests to those APIs to complete.

 

HourAPIRequestsDuration
10/api/v1/a53 sec
10/api/v1/b103 sec
11/api/v1/a1000100 ms

 

In this table, I cannot do a straight average for duration  on /a as this would yield a very skewed result; most requests are in the 100 ms category but a naive simple average would show 500+ ms for the duration.

 

What are the best approaches to showing average duration (time spans) that provide better accuracy in Power BI?  Is this something that is handled through weighting formulas written in Power Query or DAX?

 

Really it would be better (?) to expand 1000 values of 100 ms in hour 11 into discrete values and then use those to average.  I don't think that is an option in Power BI.

 

What are approaches that more veteran BI people than myself use to handle these scenarios?

 

TIA!

 

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@wilburn So like this?

Measure = 
    VAR __Table = 
        ADDCOLUMNS(
            'Table',
            "Value",[Requests] * [Duration]
        )
RETURN
    DIVIDE(SUMX(__Table,[Value]), SUM('Table'[Requests]),0)

@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Super User
Super User

@wilburn So like this?

Measure = 
    VAR __Table = 
        ADDCOLUMNS(
            'Table',
            "Value",[Requests] * [Duration]
        )
RETURN
    DIVIDE(SUMX(__Table,[Value]), SUM('Table'[Requests]),0)

@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Thank you @Greg!

 

For hundreds of millions of rows for some of the APIs, this formula was really close to the actual production data query results.  Nice job!

 

I am ordering a copy of your book!  

 

Thanks for the work you do here.

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.