Forum Discussion

angelosales150's avatar
angelosales150
Frequent Visitor
3 years ago
Solved

Filter multiples variables in a single button

Good day, community! I am looking for the solution to get the following type of filter buttons: filter1: (altura > 175) && (peso > 70) && (categoria = 'vendedor') filter2: ... filter3: ... filte...
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi angelosales150 ,

    Please try below steps:

    1. below is my test table

    Table:

    Table2:

     

    2. create a measure with below dax formula

    Measure =
    VAR cur_select =
        SELECTEDVALUE ( 'Table 2'[Filter] )
    VAR _carros =
        SELECTEDVALUE ( 'Table'[carros] )
    VAR _a =
        CALCULATETABLE (
            VALUES ( 'Table'[carros] ),
            FILTER (
                ALL ( 'Table' ),
                [altura] > 175
                    && [peso] > 70
                    && [categoria] = "vendedor"
            )
        )
    VAR _b =
        CALCULATETABLE (
            VALUES ( 'Table'[carros] ),
            FILTER (
                ALL ( 'Table' ),
                [altura] > 175
                    && [peso] > 70
                    && [categoria] = "entregador"
            )
        )
    VAR _c =
        CALCULATETABLE (
            VALUES ( 'Table'[carros] ),
            FILTER (
                ALL ( 'Table' ),
                [altura] > 170
                    && [peso] > 70
                    && [categoria] = "vendedor"
            )
        )
    VAR _d =
        CALCULATETABLE (
            VALUES ( 'Table'[carros] ),
            FILTER (
                ALL ( 'Table' ),
                [altura] > 175
                    && [peso] > 60
                    && [categoria] = "vendedor"
            )
        )
    VAR _val =
        SWITCH (
            cur_select,
            "filter1", IF ( _carros IN _a, 1 ),
            "filter2", IF ( _carros IN _b, 1 ),
            "filter3", IF ( _carros IN _c, 1 ),
            "filter4", IF ( _carros IN _d, 1 )
        )
    RETURN
        IF ( ISFILTERED ( 'Table 2'[Filter] ), _val, 1 )
    

    3. add a table visual with fields, add a slicer with field, apply this measure to table visual filter pane

    Please refer the attached .pbix file.

     

    Best regards,
    Community Support Team_Binbin Yu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.