COALESCE DAX Function (Logical)

Returns the first argument that does not evaluate to a blank value. If all arguments evaluate to blank values, BLANK is returned.

Syntax

COALESCE ( <Value1>, <Value2> [, <Value2> [, … ] ] )
Parameter Attributes Description
Value1

Any value or expression.

Value2 Repeatable

Any value or expression.

Return values

Scalar A single value of any type.

The first Value argument that is not blank.

» 2 related articles
» 3 related functions

Examples

--  COALESCE returns the first non-blank of its arguments
--  It is commonly used to provide default values to expressions
--  that might result in a blank
EVALUATE
SELECTCOLUMNS (
    TOPN ( 10, Store ),
    "Store name", Store[Store Name],
    "Manager",
        COALESCE ( Store[Area Manager], "** Not Assigned **" ),
    "Years open",
        DATEDIFF (
            Store[Open Date],
            COALESCE ( Store[Close Date], TODAY () ),
            YEAR
        )
)
ORDER BY [Manager]
Store name Manager Years open
Contoso Aurora Store ** Not Assigned ** 18
Contoso Bar Harbor Store Alvarez, Janet 17
Contoso Renton Store Bennett, Sydney 17
Contoso Spokane Store Hill, Wyatt 17
Contoso Bayonne Store Hill, Wyatt 17
Contoso Seattle No.2 Store Huang, Eugene 17
Contoso Redmond Store Johnson, Elizabeth 17
Contoso Attleboro Store Moreno, Jimmy 17
Contoso Baltimore Store Ramos, Theresa 17
Contoso Back River Store Russell, Jennifer 17
--  COALESCE can have more than two arguments
EVALUATE
VAR A = BLANK ()
VAR B = BLANK ()
VAR C = "Test"
RETURN
    { COALESCE ( A, B, C ) }

Value
Test

Related articles

Learn more about COALESCE in the following articles:

Related functions

Other related functions are:

Last update: May 12, 2021   » Contribute   » Show contributors

Contributors: Alberto Ferrari, Marco Russo

Microsoft documentation: https://docs.microsoft.com/en-us/dax/coalesce-function-dax

2018-2021 © SQLBI. All rights are reserved. Information coming from Microsoft documentation is property of Microsoft Corp. » Contact us   » Privacy Policy & Cookies

Context Transition

This function performs a Context Transition if called in a Row Context. Click to read more.

Row Context

This expression is executed in a Row Context. Click to read more.

Iterator

Not recommended

The use of this function is not recommended. See Remarks and Related functions for alternatives.

Not recommended

The use of this parameter is not recommended.

Deprecated

This function is deprecated. Jump to the Alternatives section to see the function to use.

Deprecated

This parameter is deprecated and its use is not recommended.

DirectQuery compatibility

Limitations are placed on DAX expressions allowed in measures and calculated columns.
The state below shows the DirectQuery compatibility of the DAX function.

Contribute

Want to improve the content of COALESCE? Did you find any issue?
Please, report it us! All submissions will be evaluated for possible updates of the content.


This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.