Table of contents
TOC
Collapse the table of content
Expand the table of content

ERROR Function

Owen Duncan|Last Updated: 5/22/2018

Raises an error with an error message.

Syntax

ERROR(<text>)  

Parameters

TermDefinition
textA text string containing an error message.

Return Value

None

Remarks

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

Examples

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]
BlackBlack
BlueBlue
GreyGrey
MultiMulti
NANA
RedRed
SilverSilver
Silver\BlackSilver\Black
WhiteWhite
YellowYellow

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

© 2018 Microsoft