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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
powerbi__2025
Regular Visitor

DAX measure required to count the number of students passed in all subjects when they select the sli

Hi Experts,

I'm working on a Power BI report where the requirement is to calculate the total number of students who have passed all their subjects within a selected date range.

A student is considered as "Passed" only if they have passed all subjects—even if one subject is failed, the student should be treated as "Failed".

I have a working DAX measure that gives the correct result when only today's date is selected. However, when a date range is selected using the slicer (e.g., yesterday + today), it does not return the correct count. It seems to only consider part of the range or just one date.

@lbendlin
Total_Students_Passed :=
CALCULATE(
DISTINCTCOUNT('Sheet1'[Student]),
FILTER(
VALUES('Sheet1'[Student]),
CALCULATE(
COUNTROWS(
FILTER(
'Sheet1',
'Sheet1'[Exam_Result] = "Fail"
)
)
) = 0
)
)

 

20250612_184548.jpg

2 REPLIES 2
v-achippa
Community Support
Community Support

Hi @powerbi__2025,

 

Thank you for reaching out to Microsoft Fabric Community.

 

Thank you @johnt75 for the prompt response.

 

As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided by the user resolved your issue? or let us know if you need any further assistance.
If any response resolved your issue, please mark it as "Accept as solution" and click "Yes" if you found it helpful.

 

Thanks and regards,

Anjan Kumar Chippa

johnt75
Super User
Super User

Try

Total Students Passed =
VAR StudentsNumFails =
    ADDCOLUMNS (
        VALUES ( Sheet1[Student] ),
        "@num fails", COALESCE ( CALCULATE ( COUNTROWS ( Sheet1 ), Sheet1[Exam_Result] = "Fail" ), 0 )
    )
VAR Result =
    COUNTROWS ( FILTER ( StudentsNumFails, [@num fails] = 0 ) )
RETURN
    Result

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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