COALESCE

The following section describes the syntax and usage of the COALESCE function in ActivityInfo.

Description

The COALESCE function is used to find the first non-empty value from a set of values.

Syntax

COALESCE(val1, val2, ...)

Argument Required Description
val1 Yes The first value to check.
val2 Yes The second value to check.
... No Any further values to check.

If an argument is missing or NA, it will be excluded from the calculation.

Result

The first non-empty value found, by order of input arguments (val1 will be checked first, then val2, etc.)

Example

We will be using the COALESCE function to find the first defined row value from a set of three columns.

Arguments

We will be using three Quantity fields:

  • "Value 1" (with code "val1")
  • "Value 2" (with code "val2")
  • "Value 3" (with code "val3")

Formula

COALESCE(val1,val2,val3)

Results