Forum Discussion
If Statement Total does not add up
- 2 years ago
Anonymous,
Here's an example you can adapt to your model. It evaluates the IF statement on a yearly basis. If you need it to evaluate at the day level, change "Year" to "Date".
calc = SUMX ( VALUES ( DateTable[Year] ), IF ( DateTable[Year] >= 2024, [USD_AP] - [USD_FC], [USD_AP] ) )Replace the hardcoded "2024" with the correct expression. I'm not sure what your table "A" is and how it's related to your model. The measure USD_AP has an incorrect total in your screenshot.
Thanks for the suggestion, but unfortunately this provides completely different results for me altogether.
Anonymous,
Are you able to provide sample data (table format or pbix link), screenshots of your model, and business logic?
- Anonymous2 years agoNot applicable
So I have two measures which work fine: USD_AP and USD_FC
Then I have my condition where basically when 2023, then use USD_AP and when 2024 then use USD_AP-USD_FC.
But for some reason once I do this IF statement the sum gets completely messed up eventhough the individual underlying measures work perfectly.
- DataInsights2 years ago
Super User
Anonymous,
Here's an example you can adapt to your model. It evaluates the IF statement on a yearly basis. If you need it to evaluate at the day level, change "Year" to "Date".
calc = SUMX ( VALUES ( DateTable[Year] ), IF ( DateTable[Year] >= 2024, [USD_AP] - [USD_FC], [USD_AP] ) )Replace the hardcoded "2024" with the correct expression. I'm not sure what your table "A" is and how it's related to your model. The measure USD_AP has an incorrect total in your screenshot.
- BiMica1 year agoFrequent Visitor
Worked for me. Spent a lot of time on this, thanks!