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

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
djanszentql
Helper I
Helper I

How to perform an average of an average?

I have a very simple dataset with two columns.  Instead of just taking the average (in the case below.. 9.4), I would like to take the averages of each ProcName and THEN average those together. (in the case below.. 9.167).

 

ProcNameTotalMilliseconds
Proc15
Proc110
Proc28
Proc34
Proc320
1 ACCEPTED SOLUTION
nandic
Resident Rockstar
Resident Rockstar

Hi @djanszentql ,

Attached file with calculation.




Here is the result:

Avg avg.PNG

 


Average per product =
VAR _productAvg =
    ADDCOLUMNS (
        SUMMARIZE ( 'Table', 'Table'[ProcName] ),
        "_Average"CALCULATE ( AVERAGE ( 'Table'[TotalMilliseconds] ) )
    )
RETURN
    IF (
        HASONEVALUE ( 'Table'[ProcName] ),
        AVERAGE ( 'Table'[TotalMilliseconds] ),
        AVERAGEX ( _productAvg, [_Average] )
    )

Regards,
Nemanja Andic

View solution in original post

7 REPLIES 7
nandic
Resident Rockstar
Resident Rockstar

Hi @djanszentql ,

Attached file with calculation.




Here is the result:

Avg avg.PNG

 


Average per product =
VAR _productAvg =
    ADDCOLUMNS (
        SUMMARIZE ( 'Table', 'Table'[ProcName] ),
        "_Average"CALCULATE ( AVERAGE ( 'Table'[TotalMilliseconds] ) )
    )
RETURN
    IF (
        HASONEVALUE ( 'Table'[ProcName] ),
        AVERAGE ( 'Table'[TotalMilliseconds] ),
        AVERAGEX ( _productAvg, [_Average] )
    )

Regards,
Nemanja Andic

If I wanted to add a filter on date such as this:

DATESBETWEEN('avg milliseconds roll up'[Date], MAX('avg milliseconds roll up'[Date]) - 29, MAX( 'avg milliseconds roll up'[Date]) ) )
 
Where would I go about adding that in the formula above?

Hi,
If it will be static filter (always Max date - 29 days) you can create calculate column (in my example "DatesBetween" -data type WholeNumber) and use this column to either filter data staticly or dynamically inside measure calculation.
Example static: you can add this new calculated column to Filters pane (filter for whole page, filter for whole report, filter for visualization) and to define which DatesBetween value to display.

 

avg avg 2.PNG


Example dynamic: 
On DAX formula from previous reply, you can add new condition using FILTER function. 
Ie: calculate(average(TotalMiliseconds), filter(table, DatesBetween > 0))

If it doesn't help could you send pbix file with dummy data, but with same structure as as (same tables, relationships, data types).

Regards,
Nemanja Andic

It will be static so this should work!!  Thanks for all your help!

 

One last question I have (and please let me know if I should make a separate post for this because I keep expanding the scope of the initial question for this thread).. How could I turn this into a weighted average where the third column is ExecutionCount.  To clarify, if Proc1 had 10,000 exeuctions, but Proc2 had 5,000.. I would want to apply more weight to Proc1 in the average calculation.  Again, please let me know if I should make a separate post for this.  I appreciate your help thus far!

You can keep it here as well, until we find complete solution 🙂
Could you just send expected results in Excel format (no need to upload file to dropbox/google drive, just paste here dummy values)? When i see dummy data and expected results it will be easier to reply.

It won't let me attach the excel file, but here are the values/calculation:

djanszentql_1-1613666716191.png

 

 

Thanks for provided details, attached updated version of the pbix file.



avg avg weighted.PNG

 

 


Weighted Average Measure =
VAR _Sumproduct =
    SUMX ( 'Table', 'Table'[TotalMilliseconds] * 'Table'[ExecutionCount] )
VAR _Sum =
    SUM ( 'Table'[ExecutionCount] )
RETURN
    DIVIDE ( _Sumproduct_Sum )

 

Regards,
Nemanja Andic

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.