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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
DemandMGR
Helper I
Helper I

Custom Column Help!

I am here once again asking you wonderful folks for assitance. I am having trouble writing an IF or IF(AND) or an IF(AND)ELSE formula in a custome column. Below is where I left off. I was just trying to get the first If statement going but I cant even get that right.

 

= IF(AND([QOH]= 0,[Reason] = "T",
"MNF OOS"))

 

My goal is to identify all SKUs that have [QOH] = 0 and have a [Reason] = "T"  be called 'MNF OOS".

 

Also I would like to  identify all SKUs that [QOH] = 0 and have a [Reason] = "N"  be called DC OOS.

 

Then I would want all Else be [Item Status].

 

If there is a way to do all of that in one custome column that would be ideal but I would take them sperately as well. 

 

Please let me know if you need more information. It also does not have to be an IF(AND) statement. If there is a better way to approach this I am all ears. I am so close to finishing this project and this is my last step.

 

Thank you in advanced.

1 ACCEPTED SOLUTION

Oh ok! Power query uses M not dax!

This will get you started:

https://docs.microsoft.com/en-us/powerquery-m/m-spec-conditionals

 

You don't use brackets. It should look like:

 

if condition then output else output

 

all lower case for if, then else.

 

you can also put a further of statement in the else section.

 

M had no switch statement.

 



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

View solution in original post

6 REPLIES 6
bcdobbs
Community Champion
Community Champion

I think your intial IF statement is just has the bracket in the wrong place:

 

= IF(
	AND([QOH]= 0,[Reason] = "T"),
	"MNF OOS")

 

You can do the whole thing in one step like this:

 

SWITCH ( 
	TRUE (),
	AND([QOH]= 0,[Reason] = "T"), "MNF OOS",
	AND([QOH]= 0,[Reason] = "N"), "DC OOS",
	BLANK()
)

 



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

I tried the SWITCH statement becasue ultimately I would like to get it all in one column and it gave me "The name 'SWITCH' wasn't recognized. Make sure its spelled correctly" error. That is the same problem I was getting when I was writting my original IF statement.

 

I hate to admit but I do not have any idea why this is happening to how to trouibleshoot it. 

 

 

Can you share a screen shot of where you're entering the calculated column code?



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

I am doing it as a Custom Column. The reason being is becasue I need the column to exist in Power Query so I can combine it with a conditional column I created.

 

Also wondering if I replace the BLANK() with a [COLUMN} will that still work?

 

DemandMGR_0-1643832813178.png

 

Oh ok! Power query uses M not dax!

This will get you started:

https://docs.microsoft.com/en-us/powerquery-m/m-spec-conditionals

 

You don't use brackets. It should look like:

 

if condition then output else output

 

all lower case for if, then else.

 

you can also put a further of statement in the else section.

 

M had no switch statement.

 



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

I had no idea the IF needed to be lower case in Power Query so I really appreciate that. With what you showed me I realized I could do everything I needed to do as and IF ELSE THEN statement.

 

I started with an IF and then statement and I am getting an error in the first line. Maybe you can help me with that? I am so close now and I  really appreciate all your help with this. You can see the error is under the treu expression

 

DemandMGR_1-1643836180346.png

 

 

 

 

 

 

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.