Forum Discussion

GrandeMariela's avatar
GrandeMariela
Frequent Visitor
2 years ago
Solved

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"...
  • shafiz_p's avatar
    2 years ago

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

     

    datatable:

     

     

    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:

     

    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:

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

     

     

    Hope this helps!!

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

     

     

    Best Regards,
    Shahariar Hafiz

  • shafiz_p's avatar
    shafiz_p
    2 years ago

    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:

     

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