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:
custom%20error
I’ll be waiting for your advice. Thank you.

Hi

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

Paul

Enterprise%20DNA%20Expert%20-%20Small

Hi,

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

Sam

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.