ERROR DAX Function

Raises a user specified error.

Syntax

ERROR ( <ErrorText> )
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.

» 7 related articles

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:

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

2018-2026 © SQLBI. All rights are reserved. Information coming from Microsoft documentation is property of Microsoft Corp. » Contact us   » Privacy Policy & Cookies

Context Transition

This function performs a Context Transition if called in a Row Context. Click to read more.

Row Context

This expression is executed in a Row Context. Click to read more.

Passed by Expression

This parameter is passed by expression and can be evaluated multiple times in different evaluation contexts.

Iterator

Not recommended

The use of this function is not recommended. See Remarks and Related functions for alternatives.

Not recommended

The use of this parameter is not recommended.

Deprecated

This function is deprecated. Jump to the Alternatives section to see the function to use.

Volatile

A volatile function may return a different result every time you call it, even if you provide the same arguments. Click to read more.

Deprecated

This parameter is deprecated and its use is not recommended.

DirectQuery compatibility

Limitations are placed on DAX expressions allowed in measures and calculated columns.
The state below shows the DirectQuery compatibility of the DAX function.

Contribute

Want to improve the content of ERROR? Did you find any issue?
Please, report it us! All submissions will be evaluated for possible updates of the content.