ERROR DAX Function
Raises a user specified error.
Syntax
Parameter | Attributes | Description |
---|---|---|
ErrorText |
The text of the error to be raised. |
Return values
The function does not return any value.
Remarks
This function stops the execution raising an error with the description provided as argument.
The ERROR function can be placed in a DAX expression anywhere a scalar value is expected.
Because ERROR does not define a data type, use CONVERT around ERROR to control the expected data type and avoid the variant data type of the resulting expression.
Examples
-- ERROR produces an error to inform the users about a calculation -- that needs to be aborted. DEFINE MEASURE Sales[Inflation Rate] = CALCULATE ( SELECTEDVALUE ( 'Rates'[InflationRate], CONVERT ( ERROR ( "Missing inflation rate" ), DOUBLE ) ), TREATAS ( VALUES ( 'Date'[Calendar Year Number] ), 'Rates'[Year] ) ) EVALUATE 'Rates' EVALUATE SUMMARIZECOLUMNS ( 'Date'[Calendar Year], "Rate%", [Inflation Rate] )
Related articles
Learn more about ERROR in the following articles:
-
Automatic time intelligence in Power BI
This article shows why building custom Date tables is preferable to using the automatic date/time handling capabilities of Power BI. » Read more
-
Using the SELECTEDVALUE function in DAX
This article describes how the SELECTEDVALUE DAX function simplifies the syntax required in many scenarios where you need to read a single value selected in the filter context. » Read more
-
Comparing different school terms in Power BI
This article describes how to implement the comparison between school terms. The same technique can be applied to any arbitrary time periods that do not match regular months or quarters in a calendar, such as seasons or campaigns. » Read more
-
Reading active Power BI security roles in DAX
This article describes how to read the active security roles in a Tabular model for Power BI or Analysis Services. This way, you can use measures and calculation groups to customize a report based dynamically on security roles active for the current user. » Read more
-
When are variables evaluated in DAX?
This article clarifies how DAX evaluates variables, which is important to avoid common mistakes when using DAX for the first time. » Read more
Last update: Dec 4, 2024 » Contribute » Show contributors
Contributors: Alberto Ferrari, Marco Russo, Pär Adeen
Microsoft documentation: https://docs.microsoft.com/en-us/dax/error-function