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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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