power bi dynamically add or remove matrix columns code example

Example: power bi dynamically add or remove matrix columns

// Create a slicer table and use a SWITCH measure as the matrix values:

// Slicer table (enter data)
| Column selection | Order | ...
| Column 1         | 1     |
| Column 2         | 2     |
...

// Measure 1 (slicer measure)
Column selection = MAX(Selector[Columns selection])

// Measure 2 (matrix values)
Dynamic Columns = SWITCH([Column selection];"Quantity";[Quantity total];"Value";[Value total])

//See source for detailed explaination: