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

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
Anonymous
Not applicable

Filter using a measure with Distinct

Hello

 

I’ve have a table that contains student module data. A student can have multiple modules.  There is a Module_Passed flag that is either 0 or 1

 

There are measures (see attached code) to count all rows, the distinct number of students, the distinct number of student that have Modules that have not been passed and the distinct number of students have passed all modules.

 

The issue is when I grab any of the Distinct measures e.g. the measure that counts the number of students that have passed all modules and then include the modules, I get the number for all passes and not just the count for the passed all modules

 

The pivot grand total is correct, but the values in the body of the pivot are not correct in context

 

Code and output screen prints below... 

 

I'm not sure how to fix the context. All suggestions welcome.

 

 

row_Count:=COUNTROWS(Table1)

Distinct Student_Count:=DISTINCTCOUNT(Table1[Student_ID])

Students with Modules Not Passed:=CALCULATE (
        DISTINCTCOUNT ( Table1[Student_ID] ),
        FILTER ( Table1, Table1[Module_Passed] = 0 )
    )

Students with All Modules Passed:=[Distinct Student_Count]-[Students with Modules Not Passed]

 

 Capture.PNGData.PNG

 

2 REPLIES 2
v-frfei-msft
Community Support
Community Support

Hi @Anonymous,

 

Create a measure sa below. If it doesn't meet your requirement, kindly share your excepted result to me.

 

Students with All Modules Passed2 = CALCULATE(DISTINCTCOUNT(Table1[Student_ID]),ALL(Table1))-CALCULATE(DISTINCTCOUNT(Table1[Student_ID]),FILTER(ALL(Table1),Table1[Module_Passed]=0))

Capture.PNG

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Hi @Anonymous,

 

Does that make sense? If so, kindly mark my answer as a solution to close the case.


Regards,
Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.