Forum Discussion
Using If statement for a slicer?
HI mmills2018,
AFAIK, power bi use 'and' logic with 'filter' effect to interact with other visuals, if you want to achieve advanced filter effects(e.g. OR logic, all match, not match...), I'd like to suggest you use an unconnected table as the source of a slicer. Then you can use Dax expression to interact and compare with the selection to achieve additional filter effects.
If you confused about these, please share some more detailed information to help us clarify your scenario and test to coding formula.
Regards,
Xiaoxin Sheng
Thanks for this! I have two slicers, both are an unconnected table as the source of the slicer (one is for gender and one is for race/ethnicity). I have a measure with the gender slicer that is working correctly (see below). I want to add an if/or statement into the measure for my other slicer (race/ethnicity), so if i select the race/ethnicity, it will filter for race/ethnicity. is it possible to add an if/or statement to var _value below?
- Anonymous5 years agoNot applicable
Hi mmills2018,
I modify your formula to simplify the expressions and add additional filters to the 'CTA' calculation, you can try to use the following measure if it helps:
Associates with Potential Assessment = VAR filtered = //table with public filter conditions FILTER ( 'Talent Snapshot', [Potential] <> "" ) VAR cta_add = //cta with additional filter SUMX ( FILTER ( filtered, [Gender] IN VALUES ( Gender[Gender] ) && IF ( ISFILTERED ( Race[race/ethnicity] ), [Race] IN VALUES ( Race[race/ethnicity] ), TRUE () ) ), [Count Total Associates (PME)] ) VAR cta_raw = //cta wiht raw filter SUMX ( filtered, [Count Total Associates (PME)] ) VAR _flagG = //filter flag gender ISFILTERED ( Gender[Gender] ) VAR _round = ROUND ( IF ( _flagG, MAX ( 0, DIVIDE ( cta_add, cta_raw ) ), DIVIDE ( cta_raw, SUM ( [Count Total Associates (PME)] ) ) ), 2 ) * 100 VAR _fixed = MAX ( 0, FIXED ( IF ( _flagG, cta_add, cta_raw ), 0 ) ) RETURN _round & "% (" & _fixed & ")"Regards,
Xiaoxin Sheng