Forum Discussion
Matrix Visual - creating a measure with IF statement
- 3 years ago
Hi Anonymous
Try this (modify values as you need):
Measure = var _column= SELECTEDVALUE(Sheet1[Obligation Type]) var _suma= SUM(Sheet1[Set-off / payment amount]) return SWITCH(_column, "VAT", (_suma)*0.25, "WHT 23",(_suma)*0.3, "WHT 21", (_suma)*0.21, "WHT 4(2)", (_suma)*0.x, _suma)
Hi Anonymous
1) IF is better to compare just true or false results, SWITCH is better for a variable that takes multiple values. It also makes the formula visually clearer.
2) No, there's no limit
3) Yes, you can include condition inside a SWITCH. The structure is:
SWITCH (Value,
ValueObtained, <whatever expresion>,
ValueObtained1, <whatever expresion>...
[Default value if none of the selected], <what you want to do> -->it is not mandatory to write this
)
I hope I was able to clarify your doubts. Anyway, don't hesitate to ask me again if it is not the case
Thank you for your responses!
Understood on all of your points above.
By the way, I also sent an additional reply where I tried your code but it did not work.
Anything that I can revise to make it work?