Forum Discussion
single slicer on two columns
- 8 years ago
After a LOT of beating my head against this and barking up the wrong tree (calculatedtable was NOT the answer) I was able to solve it by filtering the measures and not the dimensions. I still forget this maxim from time to time. This one was painful enough that I probably won't forget it anytime soon.
So, here's my logic for one measure. I have to filter all the measures in the output in the same way for this approach to work.Revenue =
IF (
HASONEFILTER ( 'Red/Blue'[RB Switch] ),
SWITCH (
MAX ( 'Red/Blue'[RB Switch] ),
"RED", CALCULATE (
[revcalc],
FILTER ( 'revenuetable', RELATED ( 'color'[isRed] ) = TRUE () )
),
"BLUE", CALCULATE (
[revcalc],
FILTER ( 'revenuetable', RELATED ( 'color'[isBlue] ) = TRUE () )
)
),
[revcalc]
)
I dont think the answer is going to be as simple as you hope it to be. Either you will need some calculated column that performs some logic considering Both columns, but that logic would need to be static. Or you might need to consider unpivoting the data such that instead of having a True/False for each of the red/blue columns that you have a 'Colour' column and have power BI convert all of the True values into being a corresponding value in that one column.
Naturally which direction you go will be influenced by the overall picture.
Of course you could also use multiple slicers depending on what the colours mean and how the users will be actually using the reports.