Forum Discussion

YASHASHRI's avatar
YASHASHRI
Icon for Helper I rankHelper I
2 years ago
Solved

Create slicer based on condition

I have three columns I.e Autopilot, Copilot, autopilot knowledge. These 3 columns are created on certain conditions. It consist of options like Y and N. So in the table I have opp name, opp ID, Au...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi YASHASHRI 

     

    Please try this:

    First of all, I create a set of sample:

    Then add a new table:

    Table 2 = {"autopilot","Copilot","autopilot knowledge","none"}

    Finally, add a new measure:

    MEASURE =
    VAR _NewValue =
        SELECTEDVALUE ( 'Table 2'[Value] )
    RETURN
        SWITCH (
            _NewValue,
            "autopilot", CALCULATE ( SELECTEDVALUE ( 'Table'[opp ID] ), 'Table'[autopilot] = "Y" ),
            "autopilot knowledge",
                CALCULATE (
                    SELECTEDVALUE ( 'Table'[opp ID] ),
                    'Table'[autopilot knowledge] = "Y"
                ),
            "Copilot", CALCULATE ( SELECTEDVALUE ( 'Table'[opp ID] ), 'Table'[Coilot] = "Y" ),
            "None",
                CALCULATE (
                    SELECTEDVALUE ( 'Table'[opp ID] ),
                    'Table'[autopilot] = "N"
                        && 'Table'[autopilot knowledge] = "N"
                        && 'Table'[Coilot] = "N"
                )
        )

    Add a slicer and a matrix:

     

    The result is as follow:

     

    Best Regards

    Zhengdong Xu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.