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

View all the Fabric Data Days sessions on demand. View schedule

Reply
Anonymous
Not applicable

How to distinct count by category to filter out specific result?

Hi guys,

Seeking for advice and help here,
Here are the scenario, I have student name, subject and score. Whichever a individual student have single fail subject consider as fail. The objective is to count the number of student achieve all pass.

Student NameSubjectScore
AliceMathPass
AliceScienceFail
AliceEnglishPass
DavidMathPass
DavidSciencePass
DavidEnglishPass
MikeMathFail
MikeSciencePass
MikeEnglishFail
PeterMathPass
PeterSciencePass
PeterEnglishPass

 

However, the dax measure i created
CALCULATE(DISTINCTCOUNT(Table[Student Name]), FILTER(Table,Table[Score] <> "Fail")) and this return result = 4 students

The desired outcome is 2 students (David & Peter) with all Pass.


How to derive Dax measure to count unique Student with ALL Score  = "Pass"?

1 ACCEPTED SOLUTION
VahidDM
Super User
Super User

Hi @Anonymous 

 

Try this measure:

Measure = 
Var _Count_Pass_Student = SUMMARIZE('Table','Table'[Student Name],"PASS",CALCULATE(COUNTROWS('Table'),'Table'[Score]="Pass"))
Var _Filter_Just_All_Pass = FILTER(_Count_Pass_Student,[PASS]=3)
return
COUNTROWS(_Filter_Just_All_Pass)

Output:

VahidDM_0-1657718601358.png



If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

Appreciate your Kudos!! 

Badges.jpg

LinkedIn | Twitter | Blog | YouTube 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @Anonymous ,

 

Please check the formula:

Measure = 
var tmp = SUMMARIZE('Table','Table'[Student Name],"is_pass",CALCULATE(MIN('Table'[Score]),ALLEXCEPT('Table','Table'[Student Name])))
return
COUNTROWS(FILTER(tmp,[is_pass]="Pass"))

 

Best Regards,

Jay

VahidDM
Super User
Super User

Hi @Anonymous 

 

Try this measure:

Measure = 
Var _Count_Pass_Student = SUMMARIZE('Table','Table'[Student Name],"PASS",CALCULATE(COUNTROWS('Table'),'Table'[Score]="Pass"))
Var _Filter_Just_All_Pass = FILTER(_Count_Pass_Student,[PASS]=3)
return
COUNTROWS(_Filter_Just_All_Pass)

Output:

VahidDM_0-1657718601358.png



If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

Appreciate your Kudos!! 

Badges.jpg

LinkedIn | Twitter | Blog | YouTube 

AntonioM
Solution Sage
Solution Sage

You could try

Measure = CALCULATE ( DISTINCTCOUNT ('Table'[Student Name] ) - CALCULATE( DISTINCTCOUNT('Table'[Student Name] ) ,'Table'[Score] <> "Pass"))

That will get the total number and subtract however many have at least one Fail

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