Forum Discussion

rwilcox's avatar
rwilcox
New Member
10 years ago
Solved

Adding custom column

I am trying to write the if then statement for adding a new column.

 

If the country column is null then return "USA" or return the value from the country column

 

I thought I had the statement written correctly but received an error value in every row once applied

 

 

  • Anonymous's avatar
    Anonymous
    9 years ago

    rwilcox

     

    Th formula for the NewCountryColumn should be like

     

    =IF(isblank([Country]),"USA",[Country])

     

    If this works please accept this as a solution and also give KUDOS.

     

    Cheers

     

    CheenuSIng

  • Are you doing this in Get Data or DAX?   I recommend the former. 

    The if statement in Power Query is written as follows

     

    = if [country] is null then "USA" else [country]

6 Replies

  • MattAllington's avatar
    MattAllington
    Community Champion

    Are you doing this in Get Data or DAX?   I recommend the former. 

    The if statement in Power Query is written as follows

     

    = if [country] is null then "USA" else [country]

  • Anonymous's avatar
    Anonymous
    Not applicable

    rwilcox

     

    Th formula for the NewCountryColumn should be like

     

    =IF(isblank([Country]),"USA",[Country])

     

    If this works please accept this as a solution and also give KUDOS.

     

    Cheers

     

    CheenuSIng

    • LiamCurham's avatar
      LiamCurham
      New Member

      I tried this. I was allowed click OK on the formula but I then get an ExpressionError: The name "IF" wasnt recognised.

       

      PS - I had to change my setting to US (even though I am in UK region) for previous part of Lab1 (I am doing the edX LAb) as it didnt recognise the Data format when importing CSV files, but I dont think this is related.

       

      I also tried

       

      if [country] is null then "USA" else [Country] 

       

      but i wasnt able to click on the Ok button to accept the formula

      • LiamCurham's avatar
        LiamCurham
        New Member

        I went back in and added the original systax and it now works.