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
Anonymous
Not applicable

Create filter to return rows that match in one column and differ in another

Hi all, 

 

My problem is thus: I have a column with addresses (we'll call it "Location") and a column with values A or B (we'll call it "Letter"). I need to return rows where, for the same value in Location, there are both rows with A, and some with B. 

 

Here's an example. I'm using a column called "Flag" in this case as my intention for filtering, where I would include "True" in a visual and leave "False" out. Perhaps a measure would be better, but I don't know, yet. 

 

LocationLetterFlag
CaliforniaATrue
New YorkBFalse
WyomingAFalse
CaliforniaB

True

New YorkB

False 

 

So, because there are rows for Location = California where Letter = A and rows for Location = California where Letter = B, I want to include those California rows. For the others, (Wyoming is always A, New York is always B) I would not return those rows/locations. Note that I don't know which Locations will return "True", so I don't want to write logic that is specific to strings "California", "Wyoming", "New York"... it should work for any Location where the associated Letter is sometimes A and sometimes B. 

 

What is the most efficient way for me to do this? Even if it's not necessary to create a new column, all I really want to do is filter a chart for those 'Locations' where multiple 'Letters' are associated

 

Thanks! 

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@Anonymous try this measure

 

Measure = 
VAR __tbl = CALCULATETABLE ( VALUES ( Location[Letter] ), ALLEXCEPT ( Location, Location[Location] ) )
RETURN
IF ( COUNTROWS ( __tbl ) >= 2, 1,  0 )

 

Check my latest blog post Compare Budgeted Scenarios vs. Actuals to get a summary of my favourite Power BI feature releases in 2020

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

2 REPLIES 2
parry2k
Super User
Super User

@Anonymous try this measure

 

Measure = 
VAR __tbl = CALCULATETABLE ( VALUES ( Location[Letter] ), ALLEXCEPT ( Location, Location[Location] ) )
RETURN
IF ( COUNTROWS ( __tbl ) >= 2, 1,  0 )

 

Check my latest blog post Compare Budgeted Scenarios vs. Actuals to get a summary of my favourite Power BI feature releases in 2020

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

This works great, thank you!!

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 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.