Forum Discussion

Mahonia's avatar
Mahonia
New Member
8 years ago
Solved

Filter by different column depending on user selection

I have a table with several Boolean columns and I need a user selector (either a slicer or a filter) to vary which of these columns is used to filter the visuals. The data looks like this:  Dimensi...
  • Anonymous's avatar
    Anonymous
    8 years ago

    HI Mahonia,

     

    You can refer to below steps to achieve your requirement.

     

    1. Add a selector table as the source of slicer.

    Selector = DATATABLE("Select",string,{{"OptionA"},{"OptionB"},{"OptionC"}})

     

    2. Add a measure to get the value of selected option.

    Tag = 
    IF (
        SWITCH (
            SELECTEDVALUE ( Selector[Select] ),
            "OptionA", LASTNONBLANK ( 'SampleData'[OptionA], [OptionA] ),
            "OptionB", LASTNONBLANK ( 'SampleData'[OptionB], [OptionB] ),
            "OptionC", LASTNONBLANK ( 'SampleData'[OptionC], [OptionC] )
        ),
        "Y",
        "N"
    )

    3. Add visual level filter on above measure to filter tag "Y" records.

     

    Result:

     

    Regards,

    Xiaoxin Sheng