community
cancel
Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
Upgrade Alteryx Designer in 10 Steps

Debating whether or not to upgrade to the latest version of Alteryx Designer?

LEARN MORE
Alteryx Gallery is experiencing a problem in which system emails are not being sent out. As a result, if you are attempting to sign up for a new account, you may be unable to verify your email address. We are working to solve this as soon as possible and will remove this notice once resolved.
SOLVED

Replace character with specific extension

Highlighted

Hi,

I am new to Alteryx and I have a situation that I have to replace a particular string with a country code.

For e.g We have AAPL.USD, NVDA.USD, BABA.CNY, WUBATZ.CNY. All the cells that have extension needs to be replaced by "US" and all the cells that have extension .CNY needs to be replaced with "CN".

 

I am currently using the following formula but it seems to not work correctly.

 

IF Contains([Code],"*.USD") THEN "US" ELSEIF Contains([Code],"*.CNY") THEN "CN" ELSE [Code] ENDIF

 

Please let me know if there is any better way to resolve this.

Alteryx Certified Partner

The Contains( function will only return 'true'/'false' when applied to a Boolean field. In the case of a string field, the 'true' condition is expressed as '-1'. Try this formula:

 

IF Contains([Code],".USD")=-1 THEN "US"
ELSEIF Contains([Code],".CNY")=-1 THEN "CN"
ELSE [Code] ENDIF

Thanks Charlie. This worked.

Labels