cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
willpage
Helper I
Helper I

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 II
Super User II

@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 II
Super User II

@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

Thanks @jdbuchanan71  this achieves what I need.

amitchandak
Super User IV
Super User IV

@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



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

March Update

Check it Out!

Click here to read more about the March 2021 Updates!

secondImage

The largest Power BI virtual conference

100+ sessions, 100+ speakers, Product managers, MVPs, and experts. All about Power BI. Attend online or watch the recordings.

secondImage

Experience what’s next for Power BI

See the latest Power BI innovations, updates, and demos from the Microsoft Business Applications Launch Event.