Planarly provides a full set of logical operators for testing table values and performing logical cell-wise operations between tables. It also provides IfElse()
and Where
for the conditional evaluation of formulas based on table contents.
IfElse takes one or more if
/then
(value/response) pairs and an else
response. Each if
/then
pair is evaluated in turn. If the if
, which may be a single 1x1 value or an expression that returns a single 1x1 value, evaluates to True
the associated then
is returned. If a True
value is not encountered, the else
response is returned.
IfElse()
evaluates if
/then
pairs in order and stops as soon as a True
value has been found. Below is an example where it is the middle pair that evaluates to True
. It uses relative index operators to specify values, which you can learn about in the Single Sheet tutorial or the Referencing section.
IfError takes one if
/then
(value/response) pairs and an else
response. If the if
, which may be a single cell with error message or an expression that returns an error message, the associated then
is returned. If error message is not encountered, the else
response is returned.
IfError takes one if
only. If the if
, which may be a single cell with error message or an expression that returns an error message, returns True
any other value will return False
Where()
allows you to conditionally return values based on the contents of one or more tables. Like IfElse()
above, it takes any number of value/result pairs. Unlike IfElse()
, Where()
accepts arbitrary tables in the value (where
) parameters with the additional condition that all parameters have the same dimensions.
The where
parameters must contain only boolean values. In the examples below a combination of logic and mathematical operators are used to transform the contents of table a
at the top of the sheet into table of booleans. The then
and else
arguments are then used to return appropriate values. In these simple examples Where()
is used like a simplified table comprehension, which you can read more about here.
But Where()
can be used with multiple tables to combine results based on the criteria of your choosing. Below we use some simple substitution, but as in the middle example of the above screenshot, arbitrary calculations can be performed.