Forum Discussion
Slicer option multiple conditions
- Anonymous5 years ago
Hi Anonymous ,
You can create a measure as below and check whether it can get your expected result:
Measure = VAR _sellist = ALLSELECTED ( 'SlicerTable'[colname] ) RETURN IF ( "OPTION 1" IN _sellist, COUNT ( 'Table'[A] ), 0 ) + IF ( "OPTION 2" IN _sellist, COUNT ( 'Table'[B] ), 0 ) + IF ( "OPTION 3" IN _sellist, COUNT ( 'Table'[C] ), 0 )In addition, you can refer the content in the following blogs. Hope they can give you some clue or insights...
Dynamic Measure Selection in Power BI
Change Measures Using a Slicer in Power BI
If the above ones can't help you find the solution, please share some sample data with Text format and your expected result with backend logic and special examples in order to provide you a suitable solution. Thank you.
Best Regards
Hey Anonymous ,
there is a shorter way. The combination of SWITCH with TRUE gives you a more clear solution.
Like this you can always put the if condition per line and then the result. For example:
Switch Measure =
VAR vSelectedSlicer =
SELECTEDVALUE( mySlicerTable[mySlicer] )
RETURN
SWITCH(
TRUE(),
vSelectedSlicer = "Option 1", COUNT( myTable[column 1] ),
vSelectedSlicer = "Option 2", COUNT( anotherTable[column 2] ),
vSelectedSlicer = "Option 3", COUNT( totallyDifferentTable[column 3] ),
vSelectedSlicer = "Option 4", COUNT( myTable[column 4] )
)
Read the following article about that:
DAX - The Diabolical Genius of “SWITCH TRUE” | P3 Adaptive
Thank you for quick reply!
What if I selected two or three options from the slicer? I would need multiple switch conditions right? Does the SELECTEDVALUE return a list when I click on multiple options?
- Anonymous5 years agoNot applicable
Hi Anonymous ,
You can create a measure as below and check whether it can get your expected result:
Measure = VAR _sellist = ALLSELECTED ( 'SlicerTable'[colname] ) RETURN IF ( "OPTION 1" IN _sellist, COUNT ( 'Table'[A] ), 0 ) + IF ( "OPTION 2" IN _sellist, COUNT ( 'Table'[B] ), 0 ) + IF ( "OPTION 3" IN _sellist, COUNT ( 'Table'[C] ), 0 )In addition, you can refer the content in the following blogs. Hope they can give you some clue or insights...
Dynamic Measure Selection in Power BI
Change Measures Using a Slicer in Power BI
If the above ones can't help you find the solution, please share some sample data with Text format and your expected result with backend logic and special examples in order to provide you a suitable solution. Thank you.
Best Regards