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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Greenterer
Helper I
Helper I

Filter out multiple rows based on data in just one of those rows

I have data in the following format

Student      Class
Joe             Math
Joe             English
Sally           English

Becky         Science

 

I want to filter out any students who have taken a math class, so that my results would look like this:

Student      Class

Sally           English
Becky         Science

 

My problem is that when I try to filter out anyone who took their math class that Joe's row that includes math is removed but his row that includes english class remains.  How would I get both of Joe's rows to be removed?  In other words, I only want to see people who have not taken a math class.

1 ACCEPTED SOLUTION
ArwaAldoud
Super User
Super User

Hi @Greenterer 

You can achieve this by creating a calculated column to identify students who have taken a Math class.

apply filter to your visual will display only students who have not enrolled in a Math class.

Below is the DAX formula for the calculated column.

HasTakenMath =
VAR CurrentStudent = 'Student_Class'[Student]
RETURN
IF(
CALCULATE(
COUNTROWS('Student_Class'),
'Student_Class'[Student] = CurrentStudent,
'Student_Class'[Class] = "Math"
) > 0,
TRUE(),
FALSE()
)

PBIX file attached.

 

ArwaAldoud_1-1741397798932.png

 

If this response was helpful, please accept it as a solution and give kudos to support other community members.

View solution in original post

3 REPLIES 3
danextian
Super User
Super User

Hi @Greenterer 

 

Crate a disconnected table containing the distinct classes:

danextian_0-1741440099296.png

danextian_1-1741440120365.png

Create the measure below and used it as a visual filter

Filter =
VAR _count =
    CALCULATE (
        COUNTROWS ( Student ),
        FILTER (
            ALLEXCEPT ( Student, Student[Student] ),
            Student[Class] = SELECTEDVALUE ( Class[Class] )
        )
    ) + 0
RETURN
    IF ( ISBLANK ( _count ), 1, _count )

danextian_2-1741440207799.png

danextian_3-1741440232252.png

danextian_4-1741440251612.pngdanextian_5-1741440266752.png

Please see the attached sample pbix.

 

 

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
Ashish_Mathur
Super User
Super User

Hi,

PBI file attached.

Ashish_Mathur_0-1741398674031.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
ArwaAldoud
Super User
Super User

Hi @Greenterer 

You can achieve this by creating a calculated column to identify students who have taken a Math class.

apply filter to your visual will display only students who have not enrolled in a Math class.

Below is the DAX formula for the calculated column.

HasTakenMath =
VAR CurrentStudent = 'Student_Class'[Student]
RETURN
IF(
CALCULATE(
COUNTROWS('Student_Class'),
'Student_Class'[Student] = CurrentStudent,
'Student_Class'[Class] = "Math"
) > 0,
TRUE(),
FALSE()
)

PBIX file attached.

 

ArwaAldoud_1-1741397798932.png

 

If this response was helpful, please accept it as a solution and give kudos to support other community members.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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