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.
Hi Anonymous ,
Since not certain what did your whole dataset look like, one reason that could cause this issue is that the data type of these two measures are not the same, please check whether the data type of the switch statement and the previous measure are different.
Because your calculation logic does not change, the result should not be different due to a switch statement.
Or you can consider sharing a dummy .pbix file for further discussion to determine the specific reason if the data type is same.
Best Regards,
Yingjie Li
If this post helps then please consider Accept it as the solution to help the other members find it more quickly.
- Anonymous6 years agoNot applicable
Hello, I think data type is same, so I attach here my dummy pbix file. Basically, I am trying to make a measure that calculates (Actual % / Budget %) - 1. "Payroll & Benefits" and "Indirect Expense" got right percentage, but "Fuels" not getting a right percentage which is -10/64%. I also attach a screenshot to make you understand better what I am saying.
https://drive.google.com/file/d/1hSHiM-QZ9g4arOpc7wV0a3Iu7nGCeWT5/view?usp=sharing
p.s. Construction income is negative number because it is condisered as credit, all others debit.
- v-yingjl6 years ago
Community Support
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.
- Anonymous6 years agoNot applicable
v-yingjl, I tried your code and it works! Really appreciate your help.