Power Query If condition error due to null field

gigi79

New Member
Joined
Sep 18, 2012
Messages
34
Hello all, I have a power query with an of condition that is shooting an error because the field in question is null.

Is there a way to show the error as null instead of error?

The current formula is: if product contains bill then yes else null.

For items where the product field is null it is showing error. I want it to show as null

Thanks in advance
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
When you click on one of the error cells, what message do you get. We need to understand why you are getting an error and then fix the causation.
 
Upvote 0
When you click on one of the error cells, what message do you get. We need to understand why you are getting an error and then fix the causation.
I am getting the error on the items that have null for the product.

The error is “we cannot convert the value null to type logical”
 
Upvote 0
Hello all, I have a power query with an of condition that is shooting an error because the field in question is null.

Is there a way to show the error as null instead of error?

The current formula is: if product contains bill then yes else null.

For items where the product field is null it is showing error. I want it to show as null

Thanks in advance

wrap the if step in try ... otherwise which is the M code version of Excel's IFERROR function

something like

try if Text.Contains([Product], "bill") then "yes" else null otherwise null
 
Upvote 1
Solution

Forum statistics

Threads
1,215,131
Messages
6,123,223
Members
449,091
Latest member
jeremy_bp001

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top