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.
Solved! Go to Solution.
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.