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
Gusd8
Helper I
Helper I

Create a table to generate a pass rate

Thank you for looking, I am not sure why I am struggling with this...

 

Let's say we have a 20 Classes. In those 20 classes there is a total class roster of 500 students spread between them. A student is only going to be in one class. Each class has a varying number of tests, but to pass the class you have to pass all of the tests for the class.

 

Next is a 2,000 record table that has Student ID, Test ID and Pass-Fail. (we can get class ID via a join to a class/student table). The goal is to have a Visual that shows Class/Student Count/PassRate where the pass rate is based on students that have passed all assigned tests. Small example below...

StudentTestPassFail
S1T110
S1T210
S1T310
S2T110
S2T201
S2T310
S3T101
S3T201
S3T310

 

Assuming those 3 students are in the same class...what I want to ultimately be able to see from that data is that only 1 of 3 students has passed all of their tests

ClassStudentsPass Rate
C13.33.33%

 

I don't know wht I am struggling so much with this...any assistance with solving this would be greatly appreciated. Thank you for your insight.

1 ACCEPTED SOLUTION
danextian
Super User
Super User

HI @Gusd8 

 

Given your current data, first I would compute for the count of unique students and then the student with failed subjects only (assuming that if a student has only 0s in fail column, he passes all the subjects). I'd use those calculations to compute for the pass rate. Try this formula below as a measure.

Pass Rate2 = 
VAR StudenstWithFails =
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[Student] ),
        FILTER ( 'Table', 'Table'[Fail] > 0 )
    )
VAR TotalStudents =
    DISTINCTCOUNT ( 'Table'[Student] )
RETURN
DIVIDE ( TotalStudents - StudenstWithFails, TotalStudents )

danextian_0-1654472875817.png

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

Share the download link of your PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

PBIX FILE LINK  

I generated a pbix file with a dataset that matches what I am looking to do.

I hope it makes sense. Thank You for looking...

 

danextian
Super User
Super User

HI @Gusd8 

 

Given your current data, first I would compute for the count of unique students and then the student with failed subjects only (assuming that if a student has only 0s in fail column, he passes all the subjects). I'd use those calculations to compute for the pass rate. Try this formula below as a measure.

Pass Rate2 = 
VAR StudenstWithFails =
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[Student] ),
        FILTER ( 'Table', 'Table'[Fail] > 0 )
    )
VAR TotalStudents =
    DISTINCTCOUNT ( 'Table'[Student] )
RETURN
DIVIDE ( TotalStudents - StudenstWithFails, TotalStudents )

danextian_0-1654472875817.png

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

YOU ARE AWESOME!!!

I created a sample data set and basically copy and pasted your dax and it appears to work perfectly. I am so impressed. I hadn't thought of using VAR, and I am still a bit fuzzy on exactly what is happening...but I will be working to break it down today. Thank You...again I am so impressed.

There is one other need I am going to have and that is to be able to toggle between all students and students that have passed all tests and students that still have tests to pass. If you are interested in looking...I pushed a sample file out. I will start playing with that this afternoon too.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

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!

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