Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Using Column headers as slicer

The standard answer in the message boards is to unpivot specific columns, but if if I do that, the dataset baloons from a few thousand rows to a few hundred thousand rows because im trying to unpivot...
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Anonymous ,

     

    You could try to create a column header table like

     

    Then create a measure with the SWITCH function.

    Measure =
    SWITCH (
        SELECTEDVALUE ( 'Table (2)'[Column Headers] ),
        "glycol", SUM ( 'Table'[glycol] ),
        "iron", SUM ( 'Table'[iron] ),
        "lead", SUM ( 'Table'[lead] ),
        "magnesium", SUM ( 'Table'[magnesium] )
    )
    

     

    Results:

     

    You can download the attachment for more details.

     

     

    Best Regards,

    Stephen Tao

     

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