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

compare slicer selections with each row of the table

Dear all,

 

I have a Table with a Country-Column. The user should be able to select multiple countries in a slicer. I would then like to compare the selected options with each row in the table and return true if one of the selected countries corresponds to the country in the row.  Can you help me formulate this measure? 

I find it difficult to compare the selected values of the slicer with all rows in the same table.  Can I do this in a different way?

The problem is, that the country categories are not fixed, there might arise new countries, so a fixed table for the slicer would make no sense, right ?

 

Kind regards

Susanne 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

So create one table with country values.

 

Slicer= values(Table[Country])

 

This will create one table with all country values also if some country came later in future that time you just need to refresh the model.

 

Next step is You need add this column in Slicer(Multiselect enabled)

 

Create measure

MEasure=If(max(Table[Country]) in allselected(Slicer[COUNTRY]),TRUE,FALSE)

 

Thanks & regards,
Pravin Wattamwar
www.linkedin.com/in/pravin-p-wattamwar

If I resolve your problem Mark it as a solution and give kudos.

 

View solution in original post

4 REPLIES 4
parry2k
Super User
Super User

@Anonymous it is doable, can you share the sample data and expected output. Read this post to get your answer quickly.

https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490



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

Dear @parry2k ,

 

my table T has this structure:

id          year       profit         country

5          2020       10                USA

5          2019       50                USA

4          2020       100              Vietnam

4          2018       30                Vietnam

8         2019         25                France

 

 

Each id can have multiple entries, for different years and corresponding profits. The country value is on id level . 

 

The slicer in this case should show:

USA

Vietnam

France

 

where muliple selection should be possible. 

Next I would like to compare all selected values in the slicer with each row in T and if T[country] equals one of the selected slicer options, the measure should return true for this row, else false.

 

Note to the Slicer: I cannot create a fixed table for the slicer since there might arise new countries.

The only approach I have in mind is to import a dynamic table that is included into the refresh for the slicer.

But then I dont know how to formulate the measure since I cannot iterate over the specific categories 

e.g. if(T[Country]= "France") then true()

since we don't know all categories.

 

Kind regards

Susanne

Anonymous
Not applicable

So create one table with country values.

 

Slicer= values(Table[Country])

 

This will create one table with all country values also if some country came later in future that time you just need to refresh the model.

 

Next step is You need add this column in Slicer(Multiselect enabled)

 

Create measure

MEasure=If(max(Table[Country]) in allselected(Slicer[COUNTRY]),TRUE,FALSE)

 

Thanks & regards,
Pravin Wattamwar
www.linkedin.com/in/pravin-p-wattamwar

If I resolve your problem Mark it as a solution and give kudos.

 

Anonymous
Not applicable

Awesome, thanks!

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.

Top Solution Authors