Creating custom column with IF statement ignoring the nulls

I’ve got a table of data with the column Days in Arrears, this starts at 0 and increases.
There are however fields that contain null which must be left as is.

I’ve created a custom column in power query with the following M-Code, but the null is being categorized under "In Arrears" which I don’t want.

Is there anything that I can add to this syntax that will achieve what I am looking for?

if [Days In Arrears] = 0 
then "No Arrears" 
else "In Arrears")

>Solution :

Expand your code to handle null cases in your Days In Arrears column. In clear text, just nest an if then else that picks up null:

if [Days In Arrears] = null 
then null
else if [Days In Arrears] = 0 
then "No Arrears" 
else "In Arrears"

Replace your null in then null with whatever you want to display.

Leave a Reply