Forum Discussion
wynhodgkiss
1 year agoAdvocate II
Using SWITCH with multiple conditions, SELECTEDVALUE need an option for all
I'm using SELECTEDVALUE to define 2 variables that I'm using in a switch statement like so:
NEW_MEASURE =
var _inditype = SELECTEDVALUE(MeasureTable[IndicatorType])
var _nation = SELECTEDVALUE(Brick_Account[Nation])
RETURN
SWITCH(
TRUE(),
_inditype = "Values LC" && _nation = "REPUBLIC OF IRELAND", FORMAT([IRE sales measure],"€0,0"),
_inditype = "Values LC" && _nation = "UNITED KINGDOM", FORMAT([UK GBP sales measure],"£0,0"),
_inditype = "Standard Units" && _nation = "REPUBLIC OF IRELAND", FORMAT([IRE SU measure],"0,0"),
_inditype = "Standard Units" && _nation = "UNITED KINGDOM", FORMAT([UK SU measure],"0,0"),
_inditype = "Values EUR" && _nation = "REPUBLIC OF IRELAND", FORMAT([IRE sales measure],"€0,0"),
_inditype = "Values EUR" && _nation = "UNITED KINGDOM", FORMAT([UK EUR ales measure], "€0,0"),
_inditype = "Values GBP" && _nation = "REPUBLIC OF IRELAND", FORMAT([IRE GBP sales measure],"£0,0"),
_inditype = "Values GBP" && _nation = "UNITED KINGDOM", FORMAT([UK GBP sales measure],"£0,0"))
Is there a way to either define the variable _nation differently or a new conditon within the SWITCH statement that will allow me to add an "ALL" option when both UNITED KINGDOM & REPUBLIC OF IRELAND are selected or ALL via a slicer?
ps; the above measure is used in cards and a table and is only a small sample, there are more conditions. I also have a much simpler measure to use in charts but I have the same requirement for that too
Hi wynhodgkiss
SELECTEDVALUE will return blank by default if more than one values are selected so assuming that there are only two countries, you can use something like isblank(_nation) = uk + ire
This will return the total value for card and the total value in a table at the total row only.
2 Replies
- danextianSuper User
Hi wynhodgkiss
SELECTEDVALUE will return blank by default if more than one values are selected so assuming that there are only two countries, you can use something like isblank(_nation) = uk + ire
This will return the total value for card and the total value in a table at the total row only.
- wynhodgkissAdvocate II
Perfect, thanks so much