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

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

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
March PBI video - carousel

Power BI Monthly Update - March 2025

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

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors