ERROR
Stops the evaluation with an error carrying the text given.
Group: Logical. Compatible with DAX.
Syntax
ERROR ( <text> )
| Parameter | Type | Description |
|---|---|---|
text | Text | The message the person who runs the query is shown. |
Returns
None. It gives no value: the evaluation stops with an error that carries the text.
Remarks
- The query, the measure or the visual that reaches it fails, with the text as the reason.
- A number or a date given instead of text is turned into text for the message.
IFERRORandISERRORcatch it as they catch any other error.- Only the branch of
IForSWITCHthat is chosen is evaluated, so an ERROR in the other branch does nothing. The usual use is a measure that refuses to answer where its answer would mislead, such as a price asked for several products at once.
Examples
A measure that wants one product
Over all four products the query stops with the message.
EVALUATE
ROW (
"Price",
IF (
COUNTROWS ( Products ) > 1,
ERROR ( "Choose one product to see its price" ),
MAX ( Products[Price per liter] )
)
)
Result: an error.
The same measure for one product
EVALUATE
ROW (
"Price",
CALCULATE (
IF (
COUNTROWS ( Products ) > 1,
ERROR ( "Choose one product to see its price" ),
MAX ( Products[Price per liter] )
),
Products[Product] = "IPA"
)
)
| Price |
|---|
| 64 |
Caught by IFERROR
EVALUATE
ROW ( "Result", IFERROR ( ERROR ( "Not today" ), "caught" ) )
| Result |
|---|
| caught |
Related functions
IFERROR, ISERROR, IF, HASONEVALUE.