OpenBI Docs Buy

COALESCE

The first of its arguments that is not blank.

Group: Logical. Compatible with DAX.

Syntax

COALESCE ( <expression1>, <expression2> [, <expression3>] … )
ParameterTypeDescription
expression1ValueThe first value to try.
expression2Value
repeatable
The value to use when the one before is blank; more may follow.

Returns

Same type as its values. The first of the values that is not blank, or BLANK when they all are.

Remarks

  • The values are tried from left to right, and those after the first one that is not blank are never evaluated.
  • Empty text and 0 are values, not blanks: COALESCE ( "", "x" ) is empty text.
  • COALESCE ( a, b ) is the short way to write IF ( ISBLANK ( a ), b, a ).
  • COALESCE ( [Measure], 0 ) shows 0 instead of nothing, but then every row has a value: a visual or SUMMARIZECOLUMNS no longer leaves out the rows with no data, and a table of products by day can grow to every product on every day.

Examples

The first value that is there

EVALUATE
ROW (
    "Blank, 5", COALESCE ( BLANK (), 5 ),
    "Blank, 0, 7", COALESCE ( BLANK (), 0, 7 ),
    "All blank", COALESCE ( BLANK (), BLANK () )
)
Blank, 5Blank, 0, 7All blank
50(blank)

Zero for missing liters

EVALUATE
VAR Orders =
    DATATABLE ( "Product", STRING, "Liters", INTEGER, { { "Pils", 120 }, { "Cider", BLANK () } } )
RETURN
    ADDCOLUMNS ( Orders, "Liters or 0", COALESCE ( [Liters], 0 ) )
ProductLitersLiters or 0
Pils120120
Cider(blank)0

Every row shows

The same measure as on the BLANK page, now with 0 for the products under the limit.

EVALUATE
SUMMARIZECOLUMNS (
    Products[Product],
    "Big sellers", COALESCE ( IF ( [Liters sold] > 500000, [Liters sold] ), 0 )
)
ORDER BY Products[Product]
Products[Product]Big sellers
Cider0
IPA0
Lettøl0
Pils1004326

ISBLANK, IF, BLANK, SELECTEDVALUE, DIVIDE.

Last updated · OpenBI Studio 0.3.74