Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

IF Statement formula

aliciadavoudpour
6 - Meteoroid

I have data that looks like this: 

RecordRegionCountry of Sale
1North AmericaUSA
2North AmericaUSA
3North AmericaUSA
4North AmericaUSA
5South AmericaUSA
6North AmericaUSA

 

I added the formula tool to create an IF statement to change the incorrect region name, it looks like: 

 

If [Region]="South America" and [Country of Sale]="USA" then [Region]="North America" else [region] Endif 

 

output column selected: Region; data preview: North America 

 

and my output fixes the problem, but it is throw a 0 in a different record like: 

 

RecordRegionCountry of Sale
1North AmericaUSA
2North AmericaUSA
3North AmericaUSA
40USA
5North AmericaUSA
6North AmericaUSA

 

Not sure how to fix this problem.

3 REPLIES 3
PhilipMannering
16 - Nebula
16 - Nebula

I would just use the Formula Tool to update [Region] using,

if [Country of Sale]='USA' 
then 'North America'
else [Country of Sale]
endif

Hope this solves it!

Thanks,

Phil 

aliciadavoudpour
6 - Meteoroid

It worked, thank you!

joshuaburkhow
ACE Emeritus
ACE Emeritus

@aliciadavoudpour 

 

The important thing here to remember is that you don't need to have the  [Region]="North America"  part. The fact that you are using the formula tool you are starting with a field and whatever formula you type will be what sets the value for that field. You would (just like @PhilipMannering  did) say if it's USA then its North America. Hopefully that makes sense 😉 

Joshua Burkhow - Alteryx Ace | Global Alteryx Architect @PwC | Blogger @ AlterTricks
Labels