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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

If statement generates an error for blank rows

So I'm using the following if statement to classify each "status" in the status column as either active or inactive. However, when there is a empty row, I get an error message for that row. The custom column still works, so I can just ignore this. But my brain won't allow it, please help me for my sanity.

 

I used custom column in power query to write this...

 

'''if Text.Contains([Status], "Assigned") or Text.Contains([Status], "In Progress") then "Active"

else if Text.Contains([Status], "Not in FORCE") or Text.Contains([Status], "Cancelled") then "Inactive"

else if Text.Contains([Status], "Awarded") then "Admin"

else null'''

1 ACCEPTED SOLUTION
DOLEARY85
Resident Rockstar
Resident Rockstar

Hi,

 

add this before the start of you if statement

 

 if [Status] = null then null else

 

If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

 

View solution in original post

3 REPLIES 3
DOLEARY85
Resident Rockstar
Resident Rockstar

Hi,

 

add this before the start of you if statement

 

 if [Status] = null then null else

 

If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

 

Anonymous
Not applicable

Thank you, that worked like a charm!

 

Just wondering, why do I have to keep the null you suggested AND the null I had at the end? Don't they do the same thing?

No Problem,

 

The first checking for null is just to remove the blank error as text.contains can't start looking for anything in a null field, so we're just eliminating it using that at all.

 

The last null is if anything doesn't appear in you Text.contains statements it'll just return null, if you're sure that there will always be one of the values listed in the text.contains statements then you could rewrite it to remove that part.

 

Personally i'd keep it for potential error handling if something in the data changes.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors