DIVIDE

How to Use the Power BI DAX function DIVIDE

What is the DIVIDE Function?

The DIVIDE function in Power BI DAX is a mathematical function that allows you to divide one number by another. It takes two parameters: the numerator and the denominator. The function returns the result of dividing the numerator by the denominator.

Syntax of the DIVIDE Function

The syntax for the DIVIDE function in Power BI DAX is as follows:


DIVIDE(numerator, denominator, [default value])


The numerator and denominator parameters are required, and the default value parameter is optional. If the denominator is zero, the function returns a blank value. However, you can specify a default value to return instead of a blank value.

Examples of Using the DIVIDE Function

Example 1: Calculating the Average Sales per Month

Suppose you have a sales table that contains the sales amount and the date of each sale. You can use the DIVIDE function to calculate the average sales per month as follows:


=AVERAGE(

DIVIDE(

[Sales Amount],

COUNTROWS(

VALUES(

‘Sales'[Date].[Month]

)

)

)

)


In this example, we first divide the sales amount by the number of months in the data set. The VALUES function returns a distinct list of months from the 'Sales' table. We then use the AVERAGE function to calculate the average sales per month.

Example 2: Calculating the Market Share

Suppose you have a sales table that contains the sales amount and the product name for each sale. You can use the DIVIDE function to calculate the market share for each product as follows:


=DIVIDE(

[Sales Amount],

CALCULATE(

[Total Sales Amount],

ALL(‘Sales'[Product Name])

)

)


In this example, we divide the sales amount for each product by the total sales amount for all products. The ALL function removes the filter on the product name, so we are calculating the total sales amount for all products.

Example 3: Specifying a Default Value

Suppose you have a sales table that contains the sales amount and the date of each sale. You want to calculate the average sales per month, but you do not want to return a blank value if the denominator is zero. You can specify a default value to return instead of a blank value as follows:


=AVERAGE(

DIVIDE(

[Sales Amount],

COUNTROWS(

VALUES(

‘Sales'[Date].[Month]

)

),

0

)

)


In this example, we specify a default value of 0 to return if the denominator is zero.

The DIVIDE function in Power BI DAX is a powerful tool that allows you to divide one number by another. It can be used to perform complex calculations and enhance your data analysis. By understanding the syntax and examples of using the DIVIDE function, you can unlock the full potential of Power BI DAX and improve your data analysis skills.

Power BI DAX Training Courses by G Com Solutions (0800 998 9248)

Upcoming Courses

Contact Us

    Subject

    Your Name (required)

    Company/Organisation

    Email (required)

    Telephone

    Training Course(s)

    Your Message

    Upload Example Document(s) (Zip multiple files)