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
KristofferAJ
Helper III
Helper III

Conditional column need IF AND

Hi 
I have a powerquery function adding a new column with some conditions:

= Table.AddColumn(#"Changed Type2", "(C) Enrolled", each if [#"# Enrolled - Copy"] = "NULL" then 0 else if [#"# Enrolled - Copy"] = "TERM" then 0 else if [#"# Enrolled - Copy"] = "DATA" then 0 else if [#"# Enrolled - Copy"] = "SI" then 0 else [#"# Enrolled - Copy"])


I would like to build another condition into this:
IF [Duration COLUMN] is not blank then return 0 in the (C) Enrolled column

I have tried something like this, but can't get it to work

= Table.AddColumn(#"Changed Type2", "(C) Enrolled", each if [#"# Enrolled - Copy"] = "NULL" then 0
else if [#"# Enrolled - Copy"] = "TERM" then 0
else if [#"# Enrolled - Copy"] = "DATA" then 0
else if [#"# Enrolled - Copy"] = "SI" then 0
else if [#"# Enrolled - Copy"] = null AND [Duration COLUMN] IS NOT BLANK then =0
else [#"# Enrolled - Copy"])

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

If by "blank" you mean null, then try updating the line to

else if [#"# Enrolled - Copy"] = null and [Duration COLUMN] <> null then 0

Note that M is case-sensitive so you need to use "and" instead of "AND".

 

If [Duration COLUMN] has different types of blanks like the empty string "" or white space " ", then use those instead of null above.

View solution in original post

1 REPLY 1
AlexisOlson
Super User
Super User

If by "blank" you mean null, then try updating the line to

else if [#"# Enrolled - Copy"] = null and [Duration COLUMN] <> null then 0

Note that M is case-sensitive so you need to use "and" instead of "AND".

 

If [Duration COLUMN] has different types of blanks like the empty string "" or white space " ", then use those instead of null above.

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.

Top Solution Authors