Skip to main content
All CollectionsFormula language reference
Logical & Boolean operations
Logical & Boolean operations
Updated over 10 months ago

if

Returns one value if an expression is true, and another if it is false

if(logical_test, value_if_true, [value_if_false])
if(test1, value1, test2, value2, ... [default_value]) 

You can also string multiple expressions together for example:

if(test1, "value1", test2, "value2", "default value")

In an alternate form, multiple logical tests can be tried in sequence.

  • if(true, "pass", "fail") returns "pass"

  • if(false, "pass", "fail") returns "fail"

try

try(a, [b, ...])

Tries each value until a "truthy" one is found (true/non-empty/non-null).

  • try("", "first", "second") returns "first"

  • try(null, false, true) returns true

and

and(list1, list2, [...])

Tests whether a series of values are all true/non-empty. Expects several equal length lists of booleans.

  • you may test a series of lists of the same length: a list of booleans will be returned

  • all() will flatten all lists first, then test for true/non-empty

Returns a list that has a true arg if all the elements of the lists are true at that index, and false otherwise.

  • and(true, true, true) returns true

  • and(false, true) returns false

  • and(false, false) returns false

  • and("hello", "world") returns true

  • and("hello", "") returns false

  • and("", "") returns false

  • and(list(true, true), list(true, false)) returns [true, false]

  • and(list(true, true), list(true, true)) returns [true, true]

or

or(list1, list2, [...]) 

Tests whether any of a series of values are true/non-empty. Expects several equal length lists of booleans.

Returns a list that has a true arg if any of the elements of the lists are true at that index, and false otherwise.

  • you may test a series of lists of the same length; a list of booleans will be returned

  • any() will flatten all lists first, then test for true/non-empty

none

none() 

Tests whether all of a series of values/lists are false/empty and returns true if so.

Equivalent to not(any())

not

not(boolean_expression_or_list)

Returns the opposite of a boolean operation. Given true, returns false, and vice-versa.

If given a list, applies itself to each item in the list (broadcasts). Empty lists therefore map to empty lists.


Non-Boolean interpretation

The following non-boolean-interpretation behavior may be subject to change and should not be relied upon. It exists only to preserve legacy behavior that some applications still need.

It is preferable to explicitly compare values with the = operator for all new formulas.

Given a non-boolean value, Neara attempts to map it as follows:

Value

Maps to

zero

false

Note: this can have surprising behavior with absolute values like temperatures and coordinates

NaN e.g. result of division by zero

false

empty text: ""

false

null: missing values or invalid objects

false

a list of non-boolean values

Will be interpreted according to whether it is empty or not

Mathematical boolean tests

Operator

Usage

=

equal to

eq()

equal to

<>

not equal to

neq()

not equal to

<

less than

<=

less than or equal to

>

greater than

>=

greater than or equal to

in_range()

checks if a number is within specified lower and upper bounds

Did this answer your question?