Accepts a list of fields and returns the first value that is not
null or empty. For example, when accessing a value that may
exist in any number of potential fields, a
case statement
could be used to select between the fields to identify the value
from the collection of fields. Using
coalesce()
returns the first matching value
across the selection of supplied fields. If empty string values
should be returned instead of being ignored, the
ignoreEmpty
parameter can be set to false
to change the
behavior.
Parameter | Type | Required | Default Value | Description |
---|---|---|---|---|
as | string | optional[a] | _coalesce | The field that contains the selected value, if any non-null value is found. |
expressions [b] | list of expressions | required | The list of expression candidates to select from; the first non-null result from left to right is used. | |
ignoreEmpty | boolean | optional[a] | true | If true , empty strings are treated as undefined values, that is, they are not selected. |
[a] Optional parameters use their default value unless explicitly set. [b] The parameter name |
coalesce()
Examples
Click
next to an example below to get the full details.Find the First Values in a List of Fields
Find the first values of a list of fields to normalize data using the coalesce()
function