Case() vs. If() -- when to use each
IntermediateChoose between Case() and If() based on the number of branches, readability, and short-circuit behavior to write cleaner conditional calculations.
What you'll learn
- When If() is cleaner than Case()
- When Case() is essential for multiple branches
- How nesting If() differs from a flat Case()
- Short-circuit behavior in both functions
FileMaker has two conditional functions: If(condition; trueResult; falseResult) and Case(c1; r1; c2; r2; ...; default). Both evaluate conditions and return values, but they serve different use cases. Using the right one for each situation is the difference between a readable calculation and an unreadable one.
1/4
1
If() for binary conditions
If() is the right choice when there are exactly two outcomes -- a condition is either true or false. Its three-argument form is concise and direct.
FileMaker Script
// Perfect for If() -- one condition, two outcomes: If ( Invoices::Balance > 0 ; "Outstanding" ; "Paid" ) // Also valid with default omitted (returns "" when false): If ( Contacts::IsVIP ; "* VIP" )
Sign in to track your progress and pick up where you left off.
Sign in to FM Dojo