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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Min Max and average with count in dax

Hi 

I am struggling with min max and avg in Power BI using DAX.

I have the following table.

 Student        Subject
st1                  math

st1                  eng

st1                  phy

st2                  phy

st2                  math

st2                  eng

st2                  bio

st2                  che

st2                  comp

st3                  eng

st3                  math

st1                  comp

st3                  comp

st2                  history

 

I want to cont subjects by each student and then I want to apply min max and avg on students.

Let say

Student  SubjectCount

st1           4

st2           7

st3           3

 

My desired results should be

Max_student_subject
st2 = 7
Min_student subject

st3 = 3

 

Thanks in Advance

1 ACCEPTED SOLUTION
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous,

 

Please refer to below measures:

count sub = COUNT(Data[Subject]) 

Min = RANKX(ALLSELECTED(Data[Student]),[count sub],,ASC,Dense)
Max = RANKX(ALLSELECTED(Data[Student]),[count sub],,DESC,Dense)
average = AVERAGEX(ALLSELECTED(Data),[count sub])

You need two table visuals and a card visual to display each Min, Max and Average value. You should apply visual level filters to table visuals.

1.PNG2.PNG

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
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

4 REPLIES 4
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous,

 

Please refer to below measures:

count sub = COUNT(Data[Subject]) 

Min = RANKX(ALLSELECTED(Data[Student]),[count sub],,ASC,Dense)
Max = RANKX(ALLSELECTED(Data[Student]),[count sub],,DESC,Dense)
average = AVERAGEX(ALLSELECTED(Data),[count sub])

You need two table visuals and a card visual to display each Min, Max and Average value. You should apply visual level filters to table visuals.

1.PNG2.PNG

Best regards,

Yuliana Gu

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

Hi v_yulgu-msft,

 

thanks for your reply.

Your solution is working fine but I have one issue regarding slicer filtering. If I use "ALLSELECTED" then my slicer filters are not working any more regarding this calculation.

Can you please help me regarding this.

 

Regards,

Asif

MFelix
Super User
Super User

Hi  @Anonymous,

 

Create the following measures:

Count Students = COUNT(Students[Student ])

Max students = MAXX(ALLSELECTED(Students[Student ]);[Count Students])

Min students = MINX(ALLSELECTED(Students[Student ]);[Count Students])

Average students = AVERAGEX(ALLSELECTED(Students[Student ]);[Count Students])

Be aware that this is making the selection of the selected students, if you want that your measure to be overall the full dataset no matter the selection of students change the ALLSELECTED to ALL.

 

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Anonymous
Not applicable

Hi MFelix,

thanks for your reply.

 

I have applied your method and I am getting these rows back.

png.PNG

But I want single row e.g

st3 = 3

 

Regards,

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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