Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading