I have 3 specific numbers that should start with 0, but the excel removes the leading 0. For these 3 codes, I want to add the 0 back in and am using a quick if statement to do so. Even though it does not show that there is an error in the code, I am getting a parse error / malformed if statement.
Any ideas on resolution would be helpful.
Thanks.
Solved! Go to Solution.
At a quick glance, try ELSEIF instead of ELSE IF
But also why are you using the ToString functions? You are already forcing the numbers to be strings by putting single quote around them
Also reading this function further, what is your end goal? It's a bit confusing
Hey @jpet03, how do you get on with this? Just a simplified version of what you're mentioning. Before vs after:
IF [Code] IN ('088','133','147')
THEN '0'+[Code]
ELSE [Code]
ENDIF
Some things of note in the original:
1) ToString() should wrap the field, i.e. it should be IF ToString([Code]) = '088'...
2) As your field is already a string, there's no need for ToString(), you could just use IF [Code] = '088'...
3) The then statements don't need <field> = again, you just need to state the result and nothing else i.e. ... THEN '0088'...
4) I don't actually think it makes a difference as I'm sure I've seen workflows working with both, but it should be ELSEIF i.e. one word rather than two
Some more helpers and explainers can be found in a blog I wrote a little while ago here: https://community.alteryx.com/t5/Engine-Works/Troubleshooting-Common-Formula-Expression-Errors/ba-p/...
Hope this helps!