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. |
ERROR is a DAX function that raises a user-specified error.
ERROR( ErrorText )
Argument | Properties | Description |
---|---|---|
ErrorText | The text of the error to be raised. |
None
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.
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”.
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.
2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy