ERROR

Updated on

ERROR is a DAX function that raises a user-specified error.

Syntax

ERROR( ErrorText )
Argument Properties Description
ErrorText The text of the error to be raised.

Return Values

None

Remarks

  • The ERROR function can be placed in a DAX expression anywhere a scalar value is expected.

  • This function is not supported for use in DirectQuery mode when used in calculated columns or row-level security (RLS) rules.

Example 1

The following DAX query:

DEFINE
MEASURE DimProduct[Measure] =
        IF(
            SELECTEDVALUE(DimProduct[Color]) = "Red",
            ERROR("red color encountered"),
            SELECTEDVALUE(DimProduct[Color])
        )
EVALUATE SUMMARIZECOLUMNS(DimProduct[Color], "Measure", [Measure])
ORDER BY [Color]

Fails and raises and error message containing “red color encountered”.

Example 2

The following DAX query:

DEFINE
MEASURE DimProduct[Measure] =
        IF(
            SELECTEDVALUE(DimProduct[Color]) = "Magenta",
            ERROR("magenta color encountered"),
            SELECTEDVALUE(DimProduct[Color])
        )
EVALUATE SUMMARIZECOLUMNS(DimProduct[Color], "Measure", [Measure])
ORDER BY [Color]

Returns the following table:

DimProduct[Color] [Measure]
Black Black
Blue Blue
Grey Grey
Multi Multi
NA NA
Red Red
Silver Silver
SilverBlack SilverBlack
White White
Yellow Yellow

Because Magenta is not one of the product colors, the ERROR function is not executed.

Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/dax/error-function-dax

2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy