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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

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
Skilled Sharer
Skilled Sharer

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
Skilled Sharer
Skilled Sharer

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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