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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

How do I make this if condition in dax?

I have a doubt, I have 2 columns which say the reason for rejection of a product, and I want to add a third column where I indicate the reason for rejection.
Screenshot (93).png

if it is 1 it means that the product was rejected for that reason, if it is 0 it means that it was not rejected for that reason.

the question is, I want to make a conditional "if" where I say

if NCN = 1 then "NCN"
or
if SLA = 1 then "SLA"
or
if NCN & SLA = 1 then "SLA & NCN"

If you do not meet any of the 3 conditions then "No Rej"


How would the condition be in Dax?

 This would be an example of how I want to show the information

Screenshot (94).png

 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@Anonymous 
The same thing happened, it shows no error in the syntax but at the moment of applying it does not give the desired result.
Screenshot (98).png   Screenshot (99).png

but try this
Screenshot (100).pngScreenshot (101).png

and it came out, remember that the "if" are loops and their order affects in the last example that you sent me it gave result, given that the first "if" and the second were fulfilled and as the first 2 had already been fulfilled then omitted the third, and it was only investing it by first looking for the conditional where the first 2 are 1 and if that conditional is not fulfilled then go to the next 2, Thank you very much for giving me your help and time a greeting.

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Hi @Anonymous,

 

You could use OR with the if like:

 

if(NCN = 1, "NCN",
if(SLA = 1, "SLA",
if(NCN & SLA = 1, "SLA & NCN","No Rej")))

If you do not meet any of the 3 conditions then "No Rej"

 

Let me know if it worked, if so mark as solution.

 

BR,

DR

Anonymous
Not applicable

unfortunately it doesn't work 
@Anonymous 

Screenshot (95).png

Anonymous
Not applicable

@Anonymousthat's not dax, that's M.

 

In M goes like this:

if NCN = 1 then "NCN"
else
if SLA = 1 then "SLA"
else
if NCN & SLA = 1 then "SLA & NCN" else "No Rej"

 

Try that one and let me know, if it worked mark as solution.

 

BR,

DR

Anonymous
Not applicable

@Anonymous 
no error appears when writing the formula but when applying it this appears.
Screenshot (96).png

Anonymous
Not applicable

I just saw you're concatenating the two columns in the third if, wht'a the purpose for that, they're numbers so you can't concatenate.

So what you mean is if both are 1 right?
If so then you have to use and goes like:

 

if NCN = 1 then "NCN"
else
if SLA = 1 then "SLA"
else
if NCN=1 and SLA = 1 then "SLA & NCN" else "No Rej"

Hope it worked now, if so mark as solution.

 

BR,

DR

Anonymous
Not applicable

@Anonymous 
The same thing happened, it shows no error in the syntax but at the moment of applying it does not give the desired result.
Screenshot (98).png   Screenshot (99).png

but try this
Screenshot (100).pngScreenshot (101).png

and it came out, remember that the "if" are loops and their order affects in the last example that you sent me it gave result, given that the first "if" and the second were fulfilled and as the first 2 had already been fulfilled then omitted the third, and it was only investing it by first looking for the conditional where the first 2 are 1 and if that conditional is not fulfilled then go to the next 2, Thank you very much for giving me your help and time a greeting.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.