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
avagarwal
New Member

Calculate average by group and display in levels

Hi,

 

I have data in the following format

 

StudentIdSubjectMarks
1English67%
1Maths38%
2English32%
2Maths41%
3English74%
3Maths87%

 

I need to display the number of students passed (>= 40%), failed (<40%) in a bar chart. I would like to add a slicer so that the user can select a subject or all subjects. If 'all subjects' is selected, the pass / fail count should be based on the average marks, if a specific subject is selected then based on that subject.

What is the measure that needs to be created for the same? I can add a column indicating pass / failed, but am stuck when all subjects is selected.

Thanks

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@avagarwal,

Please create the following measures in your table.

Average mark = AVERAGE(Table1[Marks])
Checkifpassed = IF([Average mark]>=0.4,1,0)
Allstudents = DISTINCTCOUNT(Table1[StudentId])
Passed = IF(COUNTROWS(VALUES(Table1[StudentId]))=1,[Checkifpassed],SUMX(VALUES(Table1[StudentId]),[Checkifpassed]))
Failed = [Allstudents]-[Passed]

1.PNG2.PNG

Regards,





View solution in original post

1 REPLY 1
Anonymous
Not applicable

@avagarwal,

Please create the following measures in your table.

Average mark = AVERAGE(Table1[Marks])
Checkifpassed = IF([Average mark]>=0.4,1,0)
Allstudents = DISTINCTCOUNT(Table1[StudentId])
Passed = IF(COUNTROWS(VALUES(Table1[StudentId]))=1,[Checkifpassed],SUMX(VALUES(Table1[StudentId]),[Checkifpassed]))
Failed = [Allstudents]-[Passed]

1.PNG2.PNG

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
Top Kudoed Authors