Forum Discussion

lauren2021's avatar
lauren2021
Frequent Visitor
5 years ago
Solved

Slicer to Select Column without Unpivoting Table

Hello,    I am looking for a way to create a slicer that will allow a user to select which column to filter by, without unpivoting the table. For example, I have a table called 'Inventory' that loo...
  • v-xulin-mstf's avatar
    v-xulin-mstf
    5 years ago

    Hi lauren2021,

     

    Try measure as:

    Measure = 
    SWITCH(
        SELECTEDVALUE('dim table'[subcategory]),
        "Red", CALCULATE(COUNT('Table'[Item Name]),FILTER(ALL('Table'),'Table'[Color]="Red")),
        "Yellow",CALCULATE(COUNT('Table'[Item Name]),FILTER(ALL('Table'),'Table'[Color]="Yellow")),
        "Blue",CALCULATE(COUNT('Table'[Item Name]),FILTER(ALL('Table'),'Table'[Color]="Blue")),
        "Square",CALCULATE(COUNT('Table'[Item Name]),FILTER(ALL('Table'),'Table'[Shape]="Square")),
        "Circle",CALCULATE(COUNT('Table'[Item Name]),FILTER(ALL('Table'),'Table'[Shape]="Circle")),
        "1",CALCULATE(COUNT('Table'[Item Name]),FILTER(ALL('Table'),'Table'[Price]=1)),
        "2",CALCULATE(COUNT('Table'[Item Name]),FILTER(ALL('Table'),'Table'[Price]=2)),BLANK())

    Here is the demo: Slicer to Select Column without Unpivoting Table 

     

    Best Regards,

    Link

     

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