Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
rwilcox
New Member

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

 

 

2 ACCEPTED SOLUTIONS
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

View solution in original post

MattAllington
Community Champion
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]



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

View solution in original post

6 REPLIES 6
MattAllington
Community Champion
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]



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.
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

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

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

so what is the solution? I tried IF(isblank([Country]),"USA",[Country]) it does not work.

The correct answer if you have added a Custom Column is the following:

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

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.