Forum Discussion
Create a table to generate a pass rate
- 4 years ago
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 )
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 )
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.