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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
pmaurizi
Frequent Visitor

Dax for calculating Average from Max values

Hello everyone,

I need a DAX for calculating the Average of certain values of a column, but considering maximum values of another column, and these, in turn, calculated only for certain records.


I attach a picture with the original table, I also put together an auxiliary calculated table to illustrate how the calculation should be done (the resulting values, and the formulas), and the final result I am looking for.


The report should only show a card with the final Average, it is not necessary to show the table with the calculations.

In the report there are time slicers.


Thank you very much!

 

pmaurizi_0-1727437153753.png

 

 

1 ACCEPTED SOLUTION
OwenAuger
Super User
Super User

Hi @pmaurizi 

I would suggest this:

 

Average of Max Time in GL over Max Grade Level per Employee = 
VAR EmployeeGradeLevel =
    INDEX (
        1,
        SUMMARIZE ( Data, Data[Employee ID], Data[Grade Level] ),
        ORDERBY ( Data[Grade Level], DESC ),
        DEFAULT,
        PARTITIONBY ( Data[Employee ID] )
    )
VAR Result =
    AVERAGEX ( EmployeeGradeLevel, CALCULATE ( MAX ( Data[Time in GL] ) ) )
RETURN
    Result

 

1. Use INDEX to compute a table containing the combinations of max Grade Level per Employee ID.

2. Then compute average of the max Time in GL for each of combination with AVERAGEX.

 

PBIX attached.

 

Does this work for you? 


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

View solution in original post

3 REPLIES 3
Kedar_Pande
Super User
Super User

Here’s a DAX measure that should work for your scenario:

Average_Max_Time_in_GL = 
VAR MaxGradeLevels =
VALUES('Source Data'[Grade Level])
VAR MaxTimes =
ADDCOLUMNS(
MaxGradeLevels,
"Max Time", CALCULATE(MAX('Source Data'[Time in GL]), 'Source Data'[Grade Level] = EARLIER('Source Data'[Grade Level]))
)
RETURN
AVERAGEX(MaxTimes, [Max Time])

Once you create this measure, you can add it to a card visualization in your report to display the average value. The slicers in your report will dynamically filter the results based on user selection. 

OwenAuger
Super User
Super User

Hi @pmaurizi 

I would suggest this:

 

Average of Max Time in GL over Max Grade Level per Employee = 
VAR EmployeeGradeLevel =
    INDEX (
        1,
        SUMMARIZE ( Data, Data[Employee ID], Data[Grade Level] ),
        ORDERBY ( Data[Grade Level], DESC ),
        DEFAULT,
        PARTITIONBY ( Data[Employee ID] )
    )
VAR Result =
    AVERAGEX ( EmployeeGradeLevel, CALCULATE ( MAX ( Data[Time in GL] ) ) )
RETURN
    Result

 

1. Use INDEX to compute a table containing the combinations of max Grade Level per Employee ID.

2. Then compute average of the max Time in GL for each of combination with AVERAGEX.

 

PBIX attached.

 

Does this work for you? 


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

You really are a genius!
It worked perfect, it is exactly what I need.
Seeing these solutions makes me realize how much I have yet to learn!!!
Thank you so much for your help!

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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