A
C
- CALCULATE
- CALCULATETABLE
- CALENDAR
- CALENDARAUTO
- CEILING
- CHISQ.DIST
- CHISQ.DIST.RT
- CHISQ.INV
- CHISQ.INV.RT
- CLOSINGBALANCEMONTH
- CLOSINGBALANCEQUARTER
- CLOSINGBALANCEYEAR
- COALESCE
- COLUMNSTATISTICS
- COMBIN
- COMBINA
- COMBINEVALUES
- CONCATENATE
- CONCATENATEX
- CONFIDENCE.NORM
- CONFIDENCE.T
- CONTAINS
- CONTAINSROW
- CONTAINSSTRING
- CONTAINSSTRINGEXACT
- CONVERT
- COS
- COSH
- COT
- COTH
- COUNT
- COUNTA
- COUNTAX
- COUNTBLANK
- COUNTROWS
- COUNTX
- COUPDAYBS
- COUPDAYS
- COUPDAYSNC
- COUPNCD
- COUPNUM
- COUPPCD
- CROSSFILTER
- CROSSJOIN
- CUMIPMT
- CUMPRINC
- CURRENCY
- CURRENTGROUP
- CUSTOMDATA
D
E
I
N
O
P
R
S
- SAMEPERIODLASTYEAR
- SAMPLE
- SEARCH
- SECOND
- SELECTCOLUMNS
- SELECTEDMEASURE
- SELECTEDMEASUREFORMATSTRING
- SELECTEDMEASURENAME
- SELECTEDVALUE
- SIGN
- SIN
- SINH
- SLN
- SQRT
- SQRTPI
- STARTOFMONTH
- STARTOFQUARTER
- STARTOFYEAR
- STDEVX.P
- STDEVX.S
- STDEV.P
- STDEV.S
- SUBSTITUTE
- SUBSTITUTEWITHINDEX
- SUM
- SUMMARIZE
- SUMMARIZECOLUMNS
- SUMX
- SWITCH
- SYD
T
U
What is the ERROR function in DAX?
The ERROR function in DAX is used to handle errors or exceptions that may occur in your calculations. The function takes two arguments: the first argument is the expression that you want to evaluate, and the second argument is the value that you want to return if the expression returns an error.
Syntax of the ERROR function
The syntax for the ERROR function is as follows:
ERROR(❰expression❱, ❰value❱)
- `❰expression❱` is the DAX expression that you want to evaluate.
- `❰value❱` is the value that you want to return if the expression returns an error.
How to use the ERROR function in Power BI
To use the ERROR function in Power BI, follow these steps:
1. Open the Power BI Desktop application and create a new report.
2. Click on the "New Measure" button in the "Modeling" tab.
3. In the formula bar, type the following formula:
Sales Error = ERROR(SUM(Sales[Amount]), 0)
In this example, we are using the ERROR function to handle any errors that may occur when we try to sum the values in the "Amount" column of the "Sales" table. If an error occurs, the function will return a value of 0.
4. Press "Enter" to evaluate the formula.
Now, you can use the "Sales Error" measure in your visuals and charts just like any other measure.
Using the ERROR function with other DAX functions
The ERROR function can be used in combination with other DAX functions to create more complex calculations. For example, you may want to use the IF function to conditionally handle errors. Here's an example:
Profit Margin = IF(SUM(Sales[Amount]) ❱ 0, DIVIDE(SUM(Sales[Profit]), SUM(Sales[Amount])), ERROR(1, 0))
In this example, we are using the IF function to first check if the sum of the values in the "Amount" column of the "Sales" table is greater than 0. If it is, we then use the DIVIDE function to calculate the profit margin. If an error occurs, the ERROR function will return a value of 0.
The ERROR function in DAX is a powerful tool that can be used to handle errors and exceptions in your calculations. By using this function, you can ensure that your calculations are accurate and that your reports and visuals are reliable. Use the syntax and examples provided in this article to get started with the ERROR function in Power BI.