Forum Discussion
DAX - IF Statement returning unexpected results
I have created an IF Statement to compare two columns and generate a result:
Risk Status = IF([MaxGood]>'Table'[QuantityRequired],"OK","AT RISK")
However, everything goes to the false statement and is coded 'AT RISK' - the highlighted results should say 'OK'
I have no idea what I'm doing wrong...I've tried hard coding in values as well and it's still not working. The below provides the same result in the table above.
Risk Status = IF([MaxGood]>5,"OK","AT RISK")
[MaxGood] is a calculated column while [QuantityRequired] is not. I feel like this is where my issue is coming from, but still no idea how to fix it.
Thank you all ahead of time.
5 Replies
- ChiragGarg2512
Solution Sage
TheSleeve , If [MaxGood] is a column in a table, the name of the table should be mentioned and use values function. This because column is related to table whereas this not the need with measure as they are part of the model. Use this dax measure:
Risk Statue = IF(values('TableName'[MaxGood] > 5, "OK", "AT RISK")
OR
Risk Statue = IF(values('TableName'[MaxGood] > [QuantityRequired], "OK", "AT RISK")
Thank You
- TheSleeveNew Member
Hi Chirag - thank you for the response. I had tried that previously and it still did not function as expected. I just tried again, just in case...still no luck.
I think there is something else going on. I just tried another scenario and watched my rows change..
Risk Status = IF('Table'[MaxGood]=1,"OK","AT RISK")When I set the condition to [MaxGood]=1 or [MaxGood]=0 some of my rows are duplicated and the values in MaxGood appear to split??
I think I need to dig in more to what exactly is happening here...
- ChiragGarg2512
Solution Sage
TheSleeve , I tried by entering the data in my software and the if condition was working as expected.
The index is just for distinction between the two (10, 12) pair.
If possible share pbix file.