DIVIDE DAX Function (Math and Trig)

Safe Divide function with ability to handle divide by zero case.

Syntax

DIVIDE ( <Numerator>, <Denominator> [, <AlternateResult>] )
Parameter Attributes Description
Numerator

Numerator.

Denominator

Denominator.

AlternateResult Optional

Optional. The alternate result to return when dividing by zero.

Return values

Scalar A single decimal value.

Result of the division between Numerator and Denominator, or AlternateResult in case there is a division by zero.

Remarks

Alternate result on divide by 0 must be a constant. By default, the AlternateResult argument is BLANK.
DIVIDE is faster than an IF statement checking whether the denominator is zero. However, DIVIDE is executed in the formula engine and it is not as fast as a native division.

» 2 related articles
» 2 related functions

Examples

--  DIVIDE performs safe division protecting from division by
--  zero. In case of zero denominator, it returns its third 
--  argument that defaults to a blank.
DEFINE
    MEASURE Sales[Unprotected Growth %] = 
        VAR CY = [Sales Amount]
        VAR PY = CALCULATE ( [Sales Amount], SAMEPERIODLASTYEAR( 'Date'[Date] ) )
        RETURN (CY - PY) / PY
    MEASURE Sales[Protected Growth %] = 
        VAR CY = [Sales Amount]
        VAR PY = CALCULATE ( [Sales Amount], SAMEPERIODLASTYEAR( 'Date'[Date] ) )
        RETURN DIVIDE ( CY - PY, PY, BLANK () )
EVALUATE
SUMMARIZECOLUMNS ( 
    'Date'[Calendar Year],
    "Unprotected Growth %", [Unprotected Growth %],
    "Protected Growth %",   [Protected Growth %]
)

Calendar Year Unprotected Growth % Protected Growth %
2007-01-01 Infinity (Blank)
2008-01-01 -0.12222543928588246 -12.22%
2009-01-01 -0.057795348753533114 -5.78%
2010-01-01 -1 -100.00%

Related articles

Learn more about DIVIDE in the following articles:

Related functions

Other related functions are:

Last update: Apr 11, 2024   » Contribute   » Show contributors

Contributors: Alberto Ferrari, Marco Russo, Kenneth Barber,

Microsoft documentation: https://docs.microsoft.com/en-us/dax/divide-function-dax

2018-2024 © 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.

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 DIVIDE? Did you find any issue?
Please, report it us! All submissions will be evaluated for possible updates of the content.


This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.