Hi,
I'm pretty new to Alteryx and could use a little help in renaming certain elements within a field. I'm using the Formula Tool with the following expression:
IF FindString([ProductTier],'Bronze1')>=0 THEN Replace([ProductTier],'Bronze1','Bronze Tier 1') ELSEIF FindString([ProductTier],'Bronze2')>=0 THEN Replace([ProductTier],'Bronze2', 'Bronze Tier 2') ELSEIF FindString([ProductTier],'Silver')>=0 THEN Replace([ProductTier],'Silver', 'Silver Tier 1') ELSEIF FindString([ProductTier],'Silver Elite')>=0 THEN Replace([ProductTier],'Silver Elite','Silver Tier 2') Else [Product] ENDIF
It works fine except that
ELSEIF FindString([ProductTier],'Silver')>=0 THEN
returns not only 'Silver', but also 'Silver Elite'. As a result the rename for 'Silver Elite' end up as 'Silver Tier 1 Elite' instead of 'Silver Tier 2'. So how do I go about specifiying that the exact word is to be found and replaced, not just any string containing the word?
Thanks.
Solved! Go to Solution.
Its becasue it finds the word "Silver" and replced with Silver Tier 1 Elite
if you change the order of your if expression then it will work . see the BOLD line that i highlighted
IF FindString([ProductTier],'Bronze1')>=0 THEN
Replace([ProductTier],'Bronze1','Bronze Tier 1')
ELSEIF FindString([ProductTier],'Bronze2')>=0 THEN
Replace([ProductTier],'Bronze2', 'Bronze Tier 2')
ELSEIF FindString([ProductTier],'Silver Elite')>=0 THEN
Replace([ProductTier],'Silver Elite','Silver Tier 2')
ELSEIF FindString([ProductTier],'Silver')>=0 THEN
Replace([ProductTier],'Silver', 'Silver Tier 1')
Else ''
ENDIF
and i am giving you another tips,
there is a tool called FInd and Replace, to help you here . you no need to write more expression like above , but just configure with the text tool what to find and what to replace :)
so easy maintanance :)
see the attched
That did it. Thanks very much!
will this comment be sent to stage?