Forum Discussion

shaileng's avatar
shaileng
Frequent Visitor
8 years ago
Solved

Dynamic switching COLUMNS using DAX

Hi there,     Quick DAX question :   - I have a table TABLE_DATA with 3 cols COL_A,COL_B,COL_C. - I have another table named TABLE_SUPPORT which holds 3 rows like "A","B" and "C - I have a...
  • v-yulgu-msft's avatar
    8 years ago

    Hi shaileng,

     

    Currently it's not available to dynamically change legend based on slicer selection. Here are two workarounds you can try.

     

    1. Create drill down report.

     

    2. Convert table structure by creating a new calculated table. This change can also be completed in Query Editor mode via "Unpivot columns". Remember to establish a one to many relationship between this new table and TABLE_SUPPORT.

    Please refer to below DAX formula.

    Sheet3 =
    UNION (
        SELECTCOLUMNS (
            Sheet2,
            "Salary", Sheet2[Salary],
            "Column", Sheet2[COL_A],
            "Selection", "A"
        ),
        SELECTCOLUMNS (
            Sheet2,
            "Salary", Sheet2[Salary],
            "Column", Sheet2[COL_B],
            "Selection", "B"
        )
    )

    For more detailed steps, please see the uploaded .pbix file.

     

    Best regards,

    Yuliana Gu