1 of 1 people found this helpful
So the structure of the formula is pretty similar (in fact Tableau has greater flexibility on the syntax)...we don't, however, have an ISODD function, but not to worry
To use the Excel style we need to use IIF (notice the extra I)...although Tableau also understands IF THEN ELSEIF ELSE END and also CASE statements.
So (and I'm assuming your social security number is already a string) you can try
the % is the MOD function, so returns the remainder from a division, so if a number%2 = 0 then its even
I've not used the calculation editor so can't guarantee I've got all the brackets in the right place!! but hopefully you get the general idea
Let me know if this doesn't do the trick, and I'll work up an example for you.
Hi Richard, here's a similar approach using the MOD function just like Simon did, with a separate calculated field to pick out the nth digit (the attached example is based on six-digit ID numbers with the fifth digit indicating gender):
INT(MID(STR([ID]),5,1)) will pick out the 5th digit.
IF [Last Digit]%2 = 0 THEN "Female" ELSE "Male" END will indicate gender.
Gender Sort.twbx 22.3 KB
Nice work Glenn...good to show the other form of IF in Tableau, and a workbook example (to prove it works!)
I find your solution more elegant, although I personally do like having the second calculated field so that i can check my work, at least as an intermediate step.
Thank you for the swift and helpful response!
Thank you for the help and for providing a workbook example, it helped a great deal to understand the underlying structure!