Forum Discussion
stsmith67
3 years agoFrequent Visitor
Change Table Columns Based on Slicer Selection
Hi All, I'm looking for a way to switch out columns in a table if a selection from a slicer is made. Example Year Slicer = 2021, show Columns A, B and C in my table or if Year Slicer = 2022, s...
Sahir_Maharaj
Super User
3 years agoHello stsmith67,
You can achieve this using the "Switch" function in DAX:
Selected Columns =
SWITCH (
SELECTEDVALUE ( 'Year'[Year] ),
2021, SELECTCOLUMNS ( Table, "A", [A], "B", [B], "C", [C] ),
2022, SELECTCOLUMNS ( Table, "A", [A], "B", [B], "D", [D], "G", [G] ),
2023, SELECTCOLUMNS ( Table, "A", [A], "D", [D], "E", [E] ),
BLANK()
)sharmil_28
1 year agoFrequent Visitor
Sahir_Maharaj
I tried but measure giving the following error.
The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value.