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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
jehoppis
Frequent Visitor

How find Max of Average

I have a buch of employees that work each day of the week, and I would like to be able to compute the average hours worked by each employee, then find the max of that.

 

For example, say I have John, Mary, and Tyler as employees working as below.

 

EmployeeDayHours
JohnMon5
MaryMon7
TylerMon3
JohnTue5
MaryTue4
TylerTue6
JohnWed5
MaryWed6
TylerWed9
JohnThu5
MaryThu3
TylerThu12
JohnFri5
MaryFri10
TylerFri5

 

Then I would like to get 

 

EmployeeAvg HoursMax Hours
John57
Mary67
Tyler77

 

If I let Avg Hours = AVERAGE(Table[Hours]), then I get what I want in the second column of the second table, but I'm not sure how to get the third column. Any help would be greatly appreciated.

1 ACCEPTED SOLUTION
djurecicK2
Super User
Super User

@jehoppis Here is how you can do it with measures.

 

AverageHours = AVERAGE('Table'[Hours])
 
Max Average Hours = MAXX(ALL('Table'[Employee]), [AverageHours])
 
Capture22.PNG
I did not copy all of your data, so in this case 5.5 is the Max Average.
 
Please mark as accepted solution if this resolves the issue.
 

 

Credit to: https://www.youtube.com/watch?v=DAvzV-4Li7A

 

View solution in original post

6 REPLIES 6
djurecicK2
Super User
Super User

@jehoppis  Please check your DAX vs what I posted earlier. You need to add [employee] or whatever field you are using for employee in the ALL statement.

Oh, thanks! Sorry, I think I read what you wrote, then watched the video where she didn't put in the column name inside of the ALL. Thanks so much! I will accept your answer.

djurecicK2
Super User
Super User

@jehoppis Here is how you can do it with measures.

 

AverageHours = AVERAGE('Table'[Hours])
 
Max Average Hours = MAXX(ALL('Table'[Employee]), [AverageHours])
 
Capture22.PNG
I did not copy all of your data, so in this case 5.5 is the Max Average.
 
Please mark as accepted solution if this resolves the issue.
 

 

Credit to: https://www.youtube.com/watch?v=DAvzV-4Li7A

 

Hmm, this does not seem to resolve the issue. When I type as you say, I get this:

jehoppis_0-1668095014264.png

I believe the ALL is causing it to look at the entire table before computing the average of each group. I watched the video, and tried replicating her MAXX of COUNTROWS, but I get 1 for each entry if I do that. Not sure why.

 

Edit: Would you be able to post the data you used as well to get 5.5?

aj1973
Community Champion
Community Champion

HI @jehoppis 

The Max Hours you want to add, is it suppose to be dynamic or constant and equal to 7? 

Because for example John can't have Max Hours = 7

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

I should have labelled Max Hours as Max of Avg Hours instead. Since the Avg Hours column is 5, 6, 7, I want the Max column to be Max(5, 6, 7) = 7 for each row. The end goal is trying to normalize Avg Hours so that I have values between 0 and 1, so I would like to do (Avg - Min)/(Max - Min).

 

Edit: As a Calculate Table, this seems to work

Table 2 = SUMMARIZE('Table', 'Table'[Employee], "Average Hours", AVERAGE('Table'[Hours]))
Max Hours = MAXX('Table 2', 'Table 2'[Average Hours])
 
but I would like to do this using measures.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors