cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rwilcox New Member
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

Accepted Solutions
CheenuSing Super Contributor
Super Contributor

Re: Adding custom column

@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

Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!

View solution in original post

Highlighted
Super User
Super User

Re: Adding custom column

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 a Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

View solution in original post

6 REPLIES 6
CheenuSing Super Contributor
Super Contributor

Re: Adding custom column

@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

Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!

View solution in original post

Highlighted
Super User
Super User

Re: Adding custom column

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 a Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

View solution in original post

LiamCurham Frequent Visitor
Frequent Visitor

Re: Adding custom column

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 Frequent Visitor
Frequent Visitor

Re: Adding custom column

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

pardeep657 Frequent Visitor
Frequent Visitor

Re: Adding custom column

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

DJPrometheus New Member
New Member

Re: Adding custom column

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

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

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Users Online
Currently online: 60 members 1,138 guests
Please welcome our newest community members: