Forum Discussion
Error in Switch Function
- 4 years ago
You still have the problem with the IF(INTERSECT()...
You need an expression with which the IF or SWITCH can establish a valid reference. Something along the lines ofSWICTH (SELECTEDVALUE(Table[Column]),....
or
IF(SELECTEDVALUE(Table[Column]),...Or
SWICTH(TRUE(),
[Measure[ <= 1000, ....If you are using SWICTH or IF in a calculated column, you can leave out the SELECTEDVALUE type expressions....
In your case you need to specify the scalar output (you cannot use a table expression such as INTERSECT) along the lines of:
Measure1 = VAR _Table = INTERSECT ( VALUES ( Brands[Brand] ), VALUES ( 'Brands + Others'[Brand] ) ) RETURN SWITCH ( TRUE (), "Brand1 combined" IN _Table, "Output1", "Brand2 combined" IN _Table, "Output2", "Brand3 combined" IN _Table, "Output3", "..." )Bear in mind that the value is calculated in order of the expressions. So if the first experssion is true, the measure returns Output1, if it return false, it moves onto the next expression and so on...
Hi Anonymous ,
Has your problem been solved? If it is solved, please mark a reply which is helpful to you.
If the problem is still not resolved, please share some sample data and expected output, which will help us to solve the problem as soon as possible.
Best Regards,
Winniz