Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Adding NULL to string returns in NULL

Hi all

 

So i create a custom column in Edit Queries. The column i add contains other columns, but it can happen that one of the columns is empty/null, i now noticed that in this case the entire string is NULL. I would expect that just no string is added or the text "null" is added to the big string. Any advise? Do i have to check every column to be null?

Date.ToText(Date.AddYears([QualifyingDate], -1)) & Number.ToText([Year] -1) & [Quarter] & Number.ToText([Month]) & [CCICat] & [SubCat] & [PanelClass] & [Company]

In this case, company is empty.

 

Thanks in advance 

  • Anonymous's avatar
    Anonymous
    6 years ago

    Hi Anonymous 

     

    Thanks for your answer.

     

    It didnt cause the problem directly.. I found a way to get it working for me:

    Date.ToText(Date.AddYears([QualifyingDate], -1)) & Number.ToText([Year] -1) & [Quarter] & Number.ToText([Month])
    & (if [CCICat] is null then "null" else [CCICat]) 
    & (if [SubCat] is null then "null" else [SubCat]) 
    & (if [PanelClass] is null then "null" else [PanelClass]) 
    & (if [Company] is null then "null" else [Company])

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    It does as you expect

     

    I created a sample table 

    str1str2str3
    asd as
    rffdd 
    wwvvgg

     

     

    This is what it shows when contatenated

     

    Try to remove below to see if thats creating problem

    Date.ToText(Date.AddYears([QualifyingDate], -1)) & Number.ToText([Year] -1)

     

     

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Anonymous 

       

      Thanks for your answer.

       

      It didnt cause the problem directly.. I found a way to get it working for me:

      Date.ToText(Date.AddYears([QualifyingDate], -1)) & Number.ToText([Year] -1) & [Quarter] & Number.ToText([Month])
      & (if [CCICat] is null then "null" else [CCICat]) 
      & (if [SubCat] is null then "null" else [SubCat]) 
      & (if [PanelClass] is null then "null" else [PanelClass]) 
      & (if [Company] is null then "null" else [Company])