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.
ErrorText must be a text constant. A number, BLANK or an expression such as a concatenation of texts is not valid as ErrorText, and DAX returns an error when it compiles the expression. A variable that contains a text constant is valid.
DAX raises the error only when it evaluates ERROR. For example, in IF ( Condition, ERROR ( “Text” ), Value ), the error is raised only when Condition is true. The error message is shown to the user of the report or of the query, and it includes the name of the measure that contains ERROR. IFERROR and ISERROR handle an error raised by ERROR in the same way as any other error: IFERROR ( ERROR ( “Text” ), 0 ) returns 0.
This function is not supported in DirectQuery mode when used in calculated columns or row-level security (RLS) rules.
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]
)
-- ERROR is raised only when the DAX engine evaluates it.
-- The year 2099 is not in the Date table, so its ERROR is never evaluated.
-- IFERROR catches the error raised for CY 2008 and returns -1.
EVALUATE
ADDCOLUMNS (
VALUES ( 'Date'[Calendar Year] ),
"Not evaluated", IF ( 'Date'[Calendar Year] = "CY 2099", ERROR ( "Year 2099 found" ), 0 ),
"Caught", IFERROR (
IF ( 'Date'[Calendar Year] = "CY 2008", ERROR ( "Year 2008 found" ), 0 ),
-1
)
)
ORDER BY 'Date'[Calendar Year]
| Calendar Year | Not evaluated | Caught |
|---|---|---|
| CY 2005 | 0 | 0 |
| CY 2006 | 0 | 0 |
| CY 2007 | 0 | 0 |
| CY 2008 | 0 | -1 |
| CY 2009 | 0 | 0 |
| CY 2010 | 0 | 0 |
| CY 2011 | 0 | 0 |
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
-
Dynamic Pareto analysis in Power BI
This article describes how to implement a dynamic Pareto calculation in Power BI based on a measure that can be selected from a slicer and dynamically filtered by other slicers in the report. » Read more
-
Controlling empty or multiple selections in calculation groups
This article describes how to control the execution of DAX code when there are either multiple or empty selections of calculation items in calculation groups. » Read more
Last update: Nov 17, 2026 » Contribute » Show contributors
Contributors: Alberto Ferrari, Marco Russo, Pär Adeen
Microsoft documentation: https://learn.microsoft.com/en-us/dax/error-function-dax