Forum Discussion

SujoyDasgupta's avatar
SujoyDasgupta
Frequent Visitor
5 years ago
Solved

Filter on comma separated multiselect field

Hi Guys, In my Datatable there is a comma separated multi select field "Region" like below image. I want to create a dropdown of Unique Regions based on this Region field. But I am getting co...
  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi SujoyDasgupta,

    The basic filter effect not able to achieve your requirement, I think you need to some more steps and tries.
    First, create a new table to extract and expand all types of regions that existed in your table and use it to create a slicer. (notice: it does not have a relationship to the raw table)

     

    Expand = 
    VAR _path =
        SUBSTITUTE (
            CONCATENATEX ( VALUES ( 'Table'[Region] ), [Region], "," ),
            ",",
            "|"
        )
    RETURN
        DISTINCT (
            SELECTCOLUMNS (
                ADDCOLUMNS (
                    GENERATESERIES ( 1, PATHLENGTH ( _path ), 1 ),
                    "Desc", PATHITEM ( _path, [Value] )
                ),
                "Desc",IF([Desc]<>"", [Desc]," ")
            )
        )

     

    Second, write a measure to compare raw table records and slicer selections to return tag and apply on it on table 'visual level filter' to filter records.

     

    Measure = 
    VAR curr =
        CONCATENATEX (
            VALUES ( 'Table'[Region] ),
            IF ( [Region] <> "", [Region], " " ),
            ","
        )
    RETURN
        IF (
            COUNTROWS (
                FILTER ( ALLSELECTED ( Expand[Desc] ), SEARCH ( [Desc], curr,, -1 ) > 0 )
            ) > 0,
            "Y",
            "N"
        )

     

    Result:

    Regards,

    Xiaoxin Sheng