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
Jpmelv
New Member

How to apply a filter to multiple columns

I pretty new to Power BI and i have been trying to create a filter to show me which countries the names have been to but what happens is it only applies to the column "Country 1"

 

NameCountry 1Country 2Country 3
JakeUKPHSG
PatrickHKSGUS
JohnUSHKUK

 

So what happens is if i filter UK it will give me 

NameCountry 1Country 2Country 3
JakeUKPHSG

 

but what i need instead is 

JakeUKPHSG
JohnUSHKUK

 

since John has been to UK also. The country column is currently 7 columns but it can be a lot more so applying filters to each column wouldnt be ok. Would appreciate any suggestion or reference material i can review for this.

1 ACCEPTED SOLUTION
v-easonf-msft
Community Support
Community Support

Hi, @Jpmelv 

You can create a new measure and apply it to visual filter pane:

filter1 = 
VAR a =
    IF (
        SELECTEDVALUE ( Table1[Country 1] )
            IN VALUES ( Country[Country Name] )
                || SELECTEDVALUE ( Table1[Country 2] )
                    IN VALUES ( Country[Country Name] )
                        || SELECTEDVALUE ( Table1[Country 3] ) IN VALUES ( Country[Country Name] ),
        1,
        0
    )
RETURN
    IF ( ISFILTERED ( Country[Country Name] ), a, 0 )

Screenshot 2022-02-17 181010.png

Best Regards,
Community Support Team _ Eason

 

View solution in original post

5 REPLIES 5
v-easonf-msft
Community Support
Community Support

Hi, @Jpmelv 

You can create a new measure and apply it to visual filter pane:

filter1 = 
VAR a =
    IF (
        SELECTEDVALUE ( Table1[Country 1] )
            IN VALUES ( Country[Country Name] )
                || SELECTEDVALUE ( Table1[Country 2] )
                    IN VALUES ( Country[Country Name] )
                        || SELECTEDVALUE ( Table1[Country 3] ) IN VALUES ( Country[Country Name] ),
        1,
        0
    )
RETURN
    IF ( ISFILTERED ( Country[Country Name] ), a, 0 )

Screenshot 2022-02-17 181010.png

Best Regards,
Community Support Team _ Eason

 

Hi there, 

 

I have a similar situation and have attempted this solution but the filter does not produce the results in the original table to then filter by. The answer is always 0 no matter which value is selected.

Thanks

Did you ever figure out this problem? I am having the exact same issue right now
parry2k
Super User
Super User

@Jpmelv the best is to unpivot your data:

 

transform data -> select name column -> right click  -> Unpivot other columns

 

you will get two new column, attribute and value, rename these as you see fit

 

Close and apply

 

Create a matrix visual, put name column on rows, attribute on columns, and value on values, also use value as a slice, now if you select UK in the slicer, you will see both the rows in the matrix visual.

 

 

Follow us on LinkedIn and YouTube.gif to our YouTube channel

 

Learn about conditional formatting at Microsoft Reactor

My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) 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.

Hi Parry 2k! thank you so much for your feedback! it got a bit complicated with the solution that you gave since im using another visual other than the list. i need to study it more i guess. what i did was i concatinated everything into one column and added a text search visual so it will show me all rows with that data. thank you again!!

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.