If

Returns result1 if the test is true; returns result2 if the test is false.

Format 

If ( test ; result1 {; result2 } )

Parameters 

test - any numeric value or logical expression

result1 - expression or field name

result2 - expression or field name

Parameters in braces { } are optional.

Data type returned 

text, number, date, time, timestamp, container

Originated in version 

6.0 or earlier

Description 

If test is True (any non-zero numeric result), FileMaker Pro returns result1. If test is False (0), result2 is returned. If test is False, and no result2 is supplied, If returns an empty result. Test must be an expression that returns either a numeric or Boolean (True, False) result.

Notes 

  • If you have more than two possible results, consider using the Case function.
  • By default, if test refers to a field that doesn't yet contain a value, If returns an empty result. To override this functionality, deselect the Do not evaluate if all referenced fields are empty checkbox.

Example 1 

If ( Country = "USA" ; "US Tech Support" ; "International Tech Support" ) returns International Tech Support, if the Country field contains France or Japan. Returns US Tech Support if the Country field contains USA.

Example 2 

If ( State = "CA" ; Subtotal * CA Tax Rate ; 0 ) returns the tax if the purchaser is a resident of California; otherwise returns 0.