cancel
Showing results for
Did you mean:
Super User

## Get the max of the average for each group

I have the following table :

EmpId DeptId WeekNumber Month NumberofCalls

1         3           4                     1          34

2         3           2                      3         59

I created a measure to calculate the average of number of calls :

AvgCalls = AVG('MyTable'[NumberofCalls])

now I want to get the max average calls by month, week.

I will be having 3 filters :

• Month
• Week

Once I select all of them, the result in the histogram bar will be the employee having the max average calls.

1 ACCEPTED SOLUTION
Community Support

Hi @AmiraBedh ,

I created a sample pbix file(see attachment) for you, please check whether that is what you want.

1. Create a measure as below to judge if the average of current employee is the max average:

``Flag = IF ( [AvgCalls] = MAXX ( ALLSELECTED ( 'MyTable' ), [AvgCalls] ), 1, 0 )``

2. Create a table visual and apply the visual-level filter with the condition(Flag is 1)

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
3 REPLIES 3
Super User

@AmiraBedh This looks like a measure aggregation problem. See my blog article about that here: https://community.powerbi.com/t5/Community-Blog/Design-Pattern-Groups-and-Super-Groups/ba-p/138149

The pattern is:
MinScoreMeasure = MINX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
MaxScoreMeasure = MAXX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
AvgScoreMeasure = AVERAGEX ( SUMMARIZE ( Table, Table[Group] , "Measure",[YourMeasure] ), [Measure])
etc.

Become an expert!: Enterprise DNA
External Tools: MSHGQM
Latest book!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...
Super User

This is what I want  :

I select a month and in the histogram I want to return the week with maximum average, following your pattern, in the histogram when I select a month I am getting all the weeks but not only the week with lax average.

I used a TOP 1 filter on the histogram but I want to do it in dax

Community Support

Hi @AmiraBedh ,

I created a sample pbix file(see attachment) for you, please check whether that is what you want.

1. Create a measure as below to judge if the average of current employee is the max average:

``Flag = IF ( [AvgCalls] = MAXX ( ALLSELECTED ( 'MyTable' ), [AvgCalls] ), 1, 0 )``

2. Create a table visual and apply the visual-level filter with the condition(Flag is 1)

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Announcements

#### 2023 Release Wave 1 Plans

Power BI release plans for 2023 release wave 1 describes all new features releasing from April 2023 through September 2023.

#### Global Power BI Training

Make sure you register today for the Power BI Summit 2023. Don't miss all of the great sessions and speakers!

#### Business Application LATAM Summit 2023

Join the biggest FREE Business Applications Event in LATAM this February.

#### Global Power Platform Bootcamp

In this bootcamp we will deep-dive into Microsoft’s Power Platform stack with hands-on sessions and labs, delivered to you by experts and community leaders.

Top Solution Authors
Top Kudoed Authors