Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

We cannot convert the value null to type Logical. Details: Value= Type=[Type]

Hi Guys

 

I am getting the above error from the following expression:

 

#"Added Conditional Column2" = Table.AddColumn(#"Added Conditional Column1", "Error Message 4", each if Text.Contains([ErrorMessage], "Status must be equal to 'Open'") then "Job Archived" else ""),

 

Don't know why the error is returned- Column [ErrorMessage] is type text, so there should be no "null's" right?

 

You help will be greatly appreciated.

 

Cheers

  • Anonymous's avatar
    Anonymous
    5 years ago

    Actually, there is no reason that you cannot have null text values. You can see them like:

    Table.SelectRows(PriorStepName, each [ErrorMessage] = null)


    But to fix your issue, you could add an if clause before the non null text is evaluated:

     

    #"Added Conditional Column2" = Table.AddColumn(#"Added Conditional Column1", "Error Message 4", each if [ErrorMessage] = null then "" else if Text.Contains([ErrorMessage], "Status must be equal to 'Open'") then "Job Archived" else ""),


    --Nate

     

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Actually, there is no reason that you cannot have null text values. You can see them like:

    Table.SelectRows(PriorStepName, each [ErrorMessage] = null)


    But to fix your issue, you could add an if clause before the non null text is evaluated:

     

    #"Added Conditional Column2" = Table.AddColumn(#"Added Conditional Column1", "Error Message 4", each if [ErrorMessage] = null then "" else if Text.Contains([ErrorMessage], "Status must be equal to 'Open'") then "Job Archived" else ""),


    --Nate

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Magic Nate!

       

      It works.  I was thinking along those lines, but obviously hashed the expression when I tried to edit it.

       

      Thanks heaps

       

      D