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.
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
Solved! Go to Solution.
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.
Best regards,
Yuliana Gu
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.
Best regards,
Yuliana Gu
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
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
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsHi MFelix,
thanks for your reply.
I have applied your method and I am getting these rows back.
But I want single row e.g
st3 = 3
Regards,
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
114 | |
99 | |
83 | |
70 | |
60 |
User | Count |
---|---|
150 | |
115 | |
104 | |
89 | |
65 |