Conditional Functions

Top  Previous  Next

Fathom Reference > Fathom Operators, Functions, and Units > Conditional Functions

if

_img391

Creates an “if” block. If the expression in parentheses after if is true, the formula returns the upper value; if not, it returns the lower. The example at left returns “big” if the value for xx is greater than 2 and “small” otherwise. See Express a Condition with an If-Statement.

switch

_img392

 

_img393

Acts like a sophisticated if; very useful for recoding attributes. It takes an optional expression inside parentheses and then evaluates each of any number of true/false expressions to determine which value to return. This is best done with a couple of examples.

Fathom interprets this by substituting age for ? in each of the expressions, starting at the top, until it finds one that is true. It returns the value to the right of the colon for that expression. So, if age is 45, the value of the entire expression is “mature.”

Here’s another example, one that might be used to recode numeric data from the census into meaningful phrases. Fathom compares the value of eduCode with each of the numbers in parentheses and returns the expression to the right of the first one that matches. If none match, it returns the value of the expression to the right of else.

To add a test value, position the caret in an existing test or result value. Press the Insert key (or Ctrl+Enter (Win) Option+Return (Mac)).

See Recode with a Switch Statement, Recode Numeric Values to Categories, and Recode Ranges of Numeric Values to Categories.