Forum Discussion
DAX SWITCH STATEMENT not working properly
- 6 years ago
Hi Anonymous ,
Based on my test and reasearch, I have added a filter in your [Construction Income (Budget)] measure and now it can show the correct result:
Construction Income (Budget) = CALCULATE(SUM('Budget For Meters'[Budget]), FILTER(ALL('Budget For Meters'),'Budget For Meters'[Description] = "1.Construction Income"))Attached the modifed dummy file, please check it: Dummy.pbix
Best Regards,
Yingjie LiIf this post helps then please consider Accept it as the solution to help the other members find it more quickly.
use daxformatter.com to put your formula into a readable format, and maybe find out where your logic breaks down.
Here you go.
- lbendlin6 years agoSuper User
here's how SWITCH() is supposed to work for your scenario (there are other options too)
SWITCH( TRUE(),<first test>,"first result",<second test>,"second result",...,"alternative result")
- Anonymous6 years agoNot applicable
Actually, I gave you wrong code. This is right one.
- lbendlin6 years agoSuper User
You are using CALCULATE() without any filter context modifiers. That means the calculation will only work on the current context of your visual which is very likely not what you want to do (and which doesn't really need Calculate). What are you actually trying to calculate?