Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
GrandeMariela
Frequent Visitor

Find and filter a text in column

Hi team, could you please give me some ideas?

 

I have two data sources to group by, something like this: 

= Table.Group(#"Added Custom1", {"name", "material", "country", "prod_line"},

{{"TOTAL", each List.Sum([TOTAL]), type nullable number},

{"product_color", each Text.Combine([product_color], ";"), type nullable text},

{"Ids", each Text.Combine([Index], ";"), type nullable text}})

 

then I have a result like this 

GrandeMariela_0-1726713764753.png

 

I need when select white or black from a slicer show the table for bedroom, same case selecting grey or silver show table for office. I can't just write product_color after prod_line because grouping will not do it correctly according with requirements. I tried with shearch() and find() function but doesn't work. show me an error 

GrandeMariela_1-1726714474511.png

filter for prod_color = FIND("silver",products_store[product_color])

 

I tried this too, don't work. 

filtered prod_color = SELECTEDVALUE(products_store[color], "no")
 
filter for prod_color = FIND(products_store[filtered prod_color],products_store[product_color])

 

Do you have some ideas to solve this. Thanks in advance

2 ACCEPTED SOLUTIONS
shafiz_p
Super User
Super User

Hi @GrandeMariela  To acheive such filter using slicer, you need to create a calculated table with single column values are distinct color.

 

datatable:

shafiz_p_3-1726719538375.png

 

 

Try the below code to create a new distinct color table:

 

ColorTable = 
DISTINCT (
    SELECTCOLUMNS (
        GENERATESERIES (1, PATHLENGTH(SUBSTITUTE(CONCATENATEX('datatable', 'datatable'[product_color], ";"), ";", "|"))),
        "Color", 
        TRIM (
            PATHITEM (
                SUBSTITUTE ( CONCATENATEX ( 'datatable', 'datatable'[product_color], ";" ), ";", "|" ),
                [Value]
            )
        )
    )
)

 

 See Image Also:

shafiz_p_0-1726718741003.png

 

Write a color search measure:

Color_Search = 
VAR searchvalue =
    SELECTEDVALUE (ColorTable[Color] )
RETURN
    IF (
        CONTAINSSTRING (
            CONCATENATEX ( 'datatable', 'datatable'[product_color], ";" ),
            searchvalue
        ),
        1,
        0
    )

 

Create slicer and table visual and place the newly created measure in "Filter on visuals" option:

shafiz_p_0-1726719285062.png

That's it!! Now if you select color in slicer, and the table will filter accordingly. See the output:

shafiz_p_1-1726719390166.pngshafiz_p_2-1726719435630.png

 

 

Hope this helps!!

If this solved your problem, please accept it as a solution!!

 

 

Best Regards,
Shahariar Hafiz

View solution in original post

The solution provided according to your problem. Now I don't know what you are trying to visualize in cards. For example, If I decided to show totals in cards and want slice by color, then the measure could be like:

Total_Value = 
VAR selectedColor = SELECTEDVALUE(ColorTable[Color])
RETURN
CALCULATE(
    SUM('datatable'[total]),
    FILTER(
        'datatable',
        CONTAINSSTRING('datatable'[product_color], selectedColor)
    )
)

This measure will calculate totals based on slicer selection. So, basically 2 measure, one for table and this one for cards to visualize totals. See image below:

shafiz_p_0-1726921572553.png

shafiz_p_1-1726921601778.png

 

Hope this helps!!
If this solved your problem, please accept it as a solution!!

 

 

 

View solution in original post

5 REPLIES 5
shafiz_p
Super User
Super User

Hi @GrandeMariela  To acheive such filter using slicer, you need to create a calculated table with single column values are distinct color.

 

datatable:

shafiz_p_3-1726719538375.png

 

 

Try the below code to create a new distinct color table:

 

ColorTable = 
DISTINCT (
    SELECTCOLUMNS (
        GENERATESERIES (1, PATHLENGTH(SUBSTITUTE(CONCATENATEX('datatable', 'datatable'[product_color], ";"), ";", "|"))),
        "Color", 
        TRIM (
            PATHITEM (
                SUBSTITUTE ( CONCATENATEX ( 'datatable', 'datatable'[product_color], ";" ), ";", "|" ),
                [Value]
            )
        )
    )
)

 

 See Image Also:

shafiz_p_0-1726718741003.png

 

Write a color search measure:

Color_Search = 
VAR searchvalue =
    SELECTEDVALUE (ColorTable[Color] )
RETURN
    IF (
        CONTAINSSTRING (
            CONCATENATEX ( 'datatable', 'datatable'[product_color], ";" ),
            searchvalue
        ),
        1,
        0
    )

 

Create slicer and table visual and place the newly created measure in "Filter on visuals" option:

shafiz_p_0-1726719285062.png

That's it!! Now if you select color in slicer, and the table will filter accordingly. See the output:

shafiz_p_1-1726719390166.pngshafiz_p_2-1726719435630.png

 

 

Hope this helps!!

If this solved your problem, please accept it as a solution!!

 

 

Best Regards,
Shahariar Hafiz

Hi Shahariar Hafiz, could you please help me with this issue I have now. After do it like you told me a cards I had in report are not filtering by slicer with ColorTable. I tried added same search measure (doesn't work in cards) and make a relatioship but only takes the sigles ones. I mean color combined like grey;silver are out of relatioship. 
Do you have any idea can help me. I really appreciate your help, thanks in advance. 

The solution provided according to your problem. Now I don't know what you are trying to visualize in cards. For example, If I decided to show totals in cards and want slice by color, then the measure could be like:

Total_Value = 
VAR selectedColor = SELECTEDVALUE(ColorTable[Color])
RETURN
CALCULATE(
    SUM('datatable'[total]),
    FILTER(
        'datatable',
        CONTAINSSTRING('datatable'[product_color], selectedColor)
    )
)

This measure will calculate totals based on slicer selection. So, basically 2 measure, one for table and this one for cards to visualize totals. See image below:

shafiz_p_0-1726921572553.png

shafiz_p_1-1726921601778.png

 

Hope this helps!!
If this solved your problem, please accept it as a solution!!

 

 

 

Thank you, I am new developing Power BI, your detailed answer helps me a lot

Jpss
Resolver II
Resolver II

hey @GrandeMariela 
i think we need a different approach here. 
you need to transform the table to look like this : 

Jpss_0-1726716850630.png

once done, you can have a colors table, and createa relationship between them

here is the solution

Jpss_1-1726716928210.png

Please see the pbix file for your reference
filterng products _jpss.pbix

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors