I have a field that I care about the last digit or the last two digits.
For example ABC07
I want to extract the number (without the 0) to compare to another number.
I want to say if the second to last digit is 0, then do Right, 1, otherwise do Right 2.
How can I write this?
If you cast these to an INT, the leading zero is "lost" anyway, so it shouldn't much matter if it exists.
If you really wanted to do the logic the way you described, you could choose:
IF LEFT(RIGHT([Field],2),1) = 0 THEN RIGHT([Field],1) ELSE RIGHT([Field],2) END
But if you're comparing numbers, I would probably just use:
Become a Viz Whiz on the Forums!
Support the Community and master Tableau.
Retrieving data ...