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
willpage
Helper II
Helper II

Slicer to filter with in operator

Hello,

 

I'm trying to solve a problem:

 

I have two tables, CSMs and Issues. The CSMs table has one column, CSM and it's text column which is a list of about 20 names.

 

The Issues table has a text column called CSM that contains the same names as the CSMs table, but sometimes there are multiple names in that column separated by commas.

 

I want to add a slicer to a page with its Field being 'CSMs'[CSM] but when a name is selected in the slicer, the Issues table is filtered not just by rows with that exact match in the CSM column but any row where the selected name exists in the CSM column.

I can't see that you can apply the in operator to a relationship between two tables, and if I split the 'Issues'[CSM] into rows on the comma it'll stuff up all my measures. 

How can I solve this, I'm happy using Power Query or DAX.

 

Many thanks in advance.

1 ACCEPTED SOLUTION
jdbuchanan71
Super User
Super User

@willpage 

I was able to get it to work for a single selection using the CONTAINSSTRING.

Measure = 
VAR _Name = SELECTEDVALUE(names[Name])
RETURN IF(CONTAINSSTRING(SELECTEDVALUE(Issues[Name]),_Name),1)

Putting that measure as a fitler on the issues table set to Is Not Blank will filter to only the rows where the names list containst the selected name.

2020-06-25_18-55-09.png

I have attached my sample file for you to look at.

2020-06-25_18-56-40.png

I can't think of a way to do it where you could select more than one name.  For that I though you would have to split the names on the issues so it could be joined to the employee table.

View solution in original post

3 REPLIES 3
jdbuchanan71
Super User
Super User

@willpage 

I was able to get it to work for a single selection using the CONTAINSSTRING.

Measure = 
VAR _Name = SELECTEDVALUE(names[Name])
RETURN IF(CONTAINSSTRING(SELECTEDVALUE(Issues[Name]),_Name),1)

Putting that measure as a fitler on the issues table set to Is Not Blank will filter to only the rows where the names list containst the selected name.

2020-06-25_18-55-09.png

I have attached my sample file for you to look at.

2020-06-25_18-56-40.png

I can't think of a way to do it where you could select more than one name.  For that I though you would have to split the names on the issues so it could be joined to the employee table.

Thanks @jdbuchanan71  this achieves what I need.

amitchandak
Super User
Super User

@willpage , Better would be that you split into rows and handle duplication because of that in the calculation .

create an index column and then split.

The other way would be the get these names into a separate table and then split it there.

and the use containsstring , find and search in the formula when every you select some value in the slicer. No need to join this new table with split names with the main table back

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.