Conditional Expressions

This cheat sheet is a quick reference for conditional expressions that are frequently used in data analysis and programming. Each expression has its syntax, a sample and a short description.

Ask NocoAI

Copy a prompt, paste it into NocoAI in any base, and replace the words in [brackets] with your own.

  • Add a formula field that shows [Overdue] when [Due Date] has passed and [Status] is not [Done]
  • Add a formula field that shows [High] when [Amount] is over [10000], otherwise [Normal]
  • Add a formula field that shows [Missing] when [Email] is empty

IF

Use the IF function to do conditional operations in programming and spreadsheet formulas. It evaluates a condition. It returns one value if the condition is TRUE, and another value if the condition is FALSE.

Syntax

IF(expr, successCase, elseCase)

Sample

IF({field} > 1, Value1, Value2)

Output
- `Value1` if `{field} > 1` evaluates to TRUE
- `Value2` otherwise

SWITCH

Use the SWITCH function to handle many cases. It compares the given expression (expr) with a series of patterns. It returns the value of the first pattern that matches. If no pattern matches, it returns the default value.

Syntax

SWITCH(expr, [pattern, value, ..., default])

Sample

SWITCH({field}, 1, 'One', 2, 'Two', '--')

Output
Switch case value based on the output of `{field}`:
- `'One'` if `{field} = 1`
- `'Two'` if `{field} = 2`
- `'--'` for the default case

AND

The AND function is a logical operator. It returns TRUE only if all its conditions are true.

Syntax

AND(expr1, [expr2,...])

Comparison operators : ==, !=, >, <, >=, <=

Sample

AND({field} > 2, {field} < 10)

Output
TRUE if both `{field} > 2` and `{field} < 10` evaluate to TRUE

OR

The OR function is also a logical operator. It returns TRUE if one or more of its conditions are true.

Syntax

OR(expr1, [expr2,...])

Comparison operators : ==, !=, >, <, >=, <=

Sample

OR({field} > 2, {field} < 10)

Output
TRUE if at least one of the conditions `{field} > 2` or `{field} < 10` evaluates to TRUE

Use logical operators together with numerical operators to build conditional expressions.

Examples:

IF({marksSecured} > 80, "GradeA", "GradeB")  
SWITCH({quarterNumber},  
    1, 'Jan-Mar',
    2, 'Apr-Jun',
    3, 'Jul-Sep',
    4, 'Oct-Dec',
    'INVALID'
)

Last updated on

Latest product updates?See Changelog
Stay in the loop? Follow us onLinkedInLinkedInYouTubeYouTubeXX