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

Creating filter for multiple values in one column

Hello, 

 

I am having an issue creating a filter that will let me filter items with mulitple values in a column separated by commas. Here is an example of the table I am using: 

Capture.PNG

I want this filter to be able to show names based on a color, with that color being in any of the three positions. For instance, If I were to click Blue I would want it to filter to Bill, David, Roger, Steven and Thomas as they all have blue somewhere in their color preference. 

 

I have tried approaching this a few different ways. I have tried splitting the columns by delimeter into separate columns. The problem when I do that is the filter will only recognize the first entry so if I were to click Blue only Thomas would show up. Also I still only want one column for Color Preference and this splits Color Preference into 3 columns: 

 

2.PNG

 

I have also tried using the delimeter to split them into multiple rows but then the issue becomes I have multiple rows repeating the same persons name: 

 

3.PNG

Is there anyway to create the filter I need?

1 ACCEPTED SOLUTION
jgeddes
Super User
Super User

One way to approach it would be to create a second table with your colors, but do not relate it to the original table. Use this table as the filter.

Create a measure that looks for the selected value in the color table and and then looks in the color preference column for that value.

filteredNames = 
var _selectedColor =
IF(
    HASONEVALUE(colors[Color]),
    SELECTEDVALUE(colors[Color])
)
var _nameCalc =
CALCULATE(
    MIN('Table'[Name]),
    FILTER('Table', CONTAINSSTRING('Table'[Color Preference], _selectedColor))
)
Return
_nameCalc

As long as you keep the color preference column in your table you will get the result you are looking for.

jgeddes_0-1670275432614.pngjgeddes_1-1670275445465.png

 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

1 REPLY 1
jgeddes
Super User
Super User

One way to approach it would be to create a second table with your colors, but do not relate it to the original table. Use this table as the filter.

Create a measure that looks for the selected value in the color table and and then looks in the color preference column for that value.

filteredNames = 
var _selectedColor =
IF(
    HASONEVALUE(colors[Color]),
    SELECTEDVALUE(colors[Color])
)
var _nameCalc =
CALCULATE(
    MIN('Table'[Name]),
    FILTER('Table', CONTAINSSTRING('Table'[Color Preference], _selectedColor))
)
Return
_nameCalc

As long as you keep the color preference column in your table you will get the result you are looking for.

jgeddes_0-1670275432614.pngjgeddes_1-1670275445465.png

 




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





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.