Forum Discussion
MikhailGG
Helper I
1 year agoSwitch with Multiple Hasonevalue() gives wrong results
I have the following formula Overview_Switch = switch( true(), HASONEVALUE('Data'[Region]), median('Sales_by_Region'[Total]), ...
- 1 year ago
iffiltered() insted of hasonevalue() solved the issue for me
Tutu_in_YYC
Super User
1 year agoThe switch statement evaluate in sequence, so if the first statement is true, it will stop there.
If you need to evalute combinations of multiple statements, you might have to do something like this:
VAR _statement1 = HASONEVALUE('Data'[Region])
VAR _statement2 = HASONEVALUE('Data'[Country])
VAR _statement3 = HASONEVALUE('Data'[Functional Area])
SWITCH(
TRUE(),
Statement1 && Statement2 && Statement3, Result1,
Statement1 && Statement2, Result2,
Statement1, Result3,
Result4
)
MikhailGG
Helper I
1 year agoThat is the problem. How can I ignore the sequence if I slice by Functional Area, but the chosen functional area has only single region and since region comes before functional area in the switch statement, I get results for region instead of functional area? Is there a different approach besides switch?
Each of those tables: sales_by_region, sales_by_country and etc have slightly different values for Total. They just have different weights depending on the table.