Forum Discussion
DW868990
3 years agoHelper IV
Switch Help when multiple selections, to return single value
Hi, I have the below switch statement - ErrorSwitch = SWITCH( TRUE(), [PageFilters] = "Product1", 1, [PageFilters] = "Product1" & "Product2", 2 ) The measure within the...
- 3 years ago
Hi,
You can expand on the logic e..g:Measure 21 =var _filter =VALUES('Table (9)'[Item])var _count = COUNTROWS(FILTER('Table (9)','Table (9)'[Item] in {"Peach","Pumpkin","Apple"}))returnSWITCH(TRUE(),_count=1 && MAX('Table (9)'[Item]) = "Peach",1,_count=2,2,
_count=3,3)
The basic idea with switch + true is the following:
SWITCH(TRUE(),
Condition1, Result1,
Condition2, Result2,
Condition3, Result3,
...)
So you can keep addiding conditions and scenarios to mathc your logic.
DW868990
3 years agoHelper IV
Thank you ValtteriN , nearly there but how does the switch statement when have to select 3 specified items and return a singular value?
ValtteriN
3 years agoCommunity Champion
Hi,
You can expand on the logic e..g:
Measure 21 =
var _filter =
VALUES('Table (9)'[Item])
var _count = COUNTROWS(FILTER('Table (9)','Table (9)'[Item] in {"Peach","Pumpkin","Apple"}))
return
SWITCH(TRUE(),
_count=1 && MAX('Table (9)'[Item]) = "Peach",1,
_count=2,2,
_count=3,3)
The basic idea with switch + true is the following:
SWITCH(TRUE(),
Condition1, Result1,
Condition2, Result2,
Condition3, Result3,
...)
So you can keep addiding conditions and scenarios to mathc your logic.
_count=3,3)
The basic idea with switch + true is the following:
SWITCH(TRUE(),
Condition1, Result1,
Condition2, Result2,
Condition3, Result3,
...)
So you can keep addiding conditions and scenarios to mathc your logic.