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
Anonymous
Not applicable

Calculate average of minimum by group

Hi, 

 

I'd like to obtain the average of a previously calculed measure of minimum per group. I'll give you an example:

 

StudentMarkGroup
John90A
Linda65A
Mark85A
Vanessa90B
George55B
Harry70B

 

What I'd like to obtain is, in first place: 

- The minimum mark my group (for Group A it would be 65, and for group B, 55)

- Get the average of these marks (AVERAGE(65,55)=60)

 

I thought of getting the minimum as a calculated column, as you can see here:

 

StudentMarkGroupMinimum
John90A65
Linda65A65
Marcus85A65
Vanessa90B55
George55B55
Harry70B55

 

But I came across a problem: my dashboard includes slicers and, if I want to filter by Group A and John mark, I'd like to obtain 90 instead of 65. As I have read, calculated columns are generated when data is loaded and doesn't care about slicers. 

 

So the other option is getting minimum by group as a measure and then get the average, again as a measure. The problem is, I suppose, that I can't create a measure that contains two values (the minimum for group A and the minimum for group B). In this case, how could I get my final measure: an average of minimum values by group that depends on slicers? I'm really stuck on this. 

 

Thanks for your help.

1 ACCEPTED SOLUTION
v-stephen-msft
Community Support
Community Support

Hi @Anonymous ,

 

If you want your minimun filtered by the slicer, you may create the measure instead of the calculated column.

 

This is the Measure vs. Calculated columns blog:

 

https://www.sqlbi.com/articles/calculated-columns-and-measures-in-dax/

 

https://insightsoftware.com/blog/calculated-columns-vs-measures/

 

 

Back to your question, the following steps are my solution.

 

1.Create the Minimun measure.

Minimum = CALCULATE(MIN('Table'[Mark]),ALLEXCEPT('Table','Table'[Group]))

 

2.Create the Average measure.

Average = AVERAGEX('Table',[Minimum])

 

2.png

 

They can be filtered by the slicer.

result10271040.gif

 

 

You can check more details from here.

 

 

 

Best Regards,

Stephen Tao

 

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

View solution in original post

2 REPLIES 2
v-stephen-msft
Community Support
Community Support

Hi @Anonymous ,

 

If you want your minimun filtered by the slicer, you may create the measure instead of the calculated column.

 

This is the Measure vs. Calculated columns blog:

 

https://www.sqlbi.com/articles/calculated-columns-and-measures-in-dax/

 

https://insightsoftware.com/blog/calculated-columns-vs-measures/

 

 

Back to your question, the following steps are my solution.

 

1.Create the Minimun measure.

Minimum = CALCULATE(MIN('Table'[Mark]),ALLEXCEPT('Table','Table'[Group]))

 

2.Create the Average measure.

Average = AVERAGEX('Table',[Minimum])

 

2.png

 

They can be filtered by the slicer.

result10271040.gif

 

 

You can check more details from here.

 

 

 

Best Regards,

Stephen Tao

 

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

amitchandak
Super User
Super User

@Anonymous , Not very clear , Try a measure like

 

AverageX(values(Table[Group]), calculate(min(Table[Mark]), filter(allselected(Table), Table[Group] = max(Table[Group]))))

or

 

AverageX(values(Table[Group]), calculate(min(Table[Mark]), filter(all(Table), Table[Group] = max(Table[Group]))))

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.