Custom column formula error in Power BI - IF statement

Hello everybody,

I tried adding a custom column but Power BI prompted an error saying, “Token Eof expected.” I then changed the null values using the “replace values” function. I don’t know what the problem is. Here is the screenshot for your reference:
I’ll be waiting for your advice. Thank you.


Syntax is
= if [Country Name] = null then … else …




You can use “Null” without the quotes, or you could use the ISBLANK DAX function to fix it.

In this case, you should note the following:

  • When the source is a CSV file and the field is empty, the query will show it as “empty string”. So the value “” is true and the preview will appear as blank.
  • When the source is other (XLS, XLSX, ACCDB, etc) and the field is empty, the query will show it as “null value”, and the value “” is false. The preview will appear as null.

As an alternative you could complete this logic as a calculated column, which in my view would likely be a bit easier.

Personally I rarely use the custom column feature in the query editor because a can usually get what I need done an easier way using another option in Power BI


Thanks to the contributors of this post. Due to the length by which this post has been active, we are tagging it as Solved. For further questions related to this post, please make a new thread.