Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
TheSleeve
New Member

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'

Screenshot 2023-09-28 110244.png

 

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 5
ChiragGarg2512
Solution Sage
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

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...

@TheSleeve , I tried by entering the data in my software and the if condition was working as expected.

ChiragGarg2512_0-1695929929447.png

The index is just for distinction between the two (10, 12) pair.

If possible share pbix file.

 

I don't think I can share the pbix due to sensitivity of the data. Here is what happens if I set [MaxGood] = 1 ... plus all the other columns with sensitive data masked. You can see when I set the condition to [MaxGood]=1 the order gets split (only on some) into multiple columns and splits the MaxGood value along with it. If I set the condition to [MaxGood]=2 (or any number greater than 2) then the Order column matches each order into a single row. I have Googled many things with no luck, but I think the issue is somewhere in my data pull and not the DAX. I will keep looking.

 

Picture1.png

@TheSleeve If the work done is by creating column than an advice would be to work in table view.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors