Forum Discussion

gghlyon's avatar
gghlyon
Frequent Visitor
7 years ago
Solved

Dynamic Column Names for Matrix Visual using Sliced Measures

Hello, I have built a P&L report, and have a question regarding the column headers in a matrix, whether these can be set dynamically.  Let me set the scene.   The measures in the matrix all work w...
  • mattneil's avatar
    7 years ago

    Hi gghlyon 

     

    I've got an option that hopefully won't need much rework in your report

     

    Create a mapping table which has the combinations of headers you want for the selection of your comparison in the slicer

     

    Then in your matrix put TableHeaders in the Columns.

     

    Finally, you'll need to create a "master" measure for use in the Values section of the matrix visual.  This measure makes use of the SWITCH function to show the relevant values for the column header.  You're essentially mapping your desired column header names to your existing Measures in this formula

    MatrixValues = SWITCH(MAX(Mappings[TableHeaders]),
                    "Actual",[Actuals],
                    "Budget",[Budgets],
                    "Forecast",[Forecasts],
                    "Var Act vs Fcst",[Actuals] - [Forecasts],
                    "Var Act vs Bud",[Actuals] - [Budgets])

    I've attached a prototype as a .pbix here.  Inspiration from Matt Allington's excellent article on using SWITCH in a matrix

    Hope that helps, let me know how it goes for you

     

    Cheers,

    Matt