# DIVIDE

## Y ## 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) Power BI DAX Intensive Training Course £1,050.00 – £26,550.00 Select optionsContinue Loading Done Power BI DAX Introduction £395.00 – £9,750.00 Select optionsContinue Loading Done Power BI DAX Intermediate £395.00 – £9,750.00 Select optionsContinue Loading Done Power BI DAX Advanced £395.00 – £9,750.00 Select optionsContinue Loading Done Upcoming Courses 6-8 Jun 23 (London or Online)8-10 Aug 23 (London or Online)24-26 Oct 23 (London or Online) Contact Us Subject Your Name (required) Company/Organisation Email (required) Telephone Training Course(s) Power BI Intensive TrainingPower BI introduction Power BI IntermediatePower BI AdvancedDAXPower Query MPower BI CertificationPower BI AdministrationPower PlatformPower AutomatePower AppsOTHER Your Message Upload Example Document(s) (Zip multiple files) ```
``` ```
``` ```
``` ```
``` ```
``` ```