0
0
Power-biHow-ToBeginner ยท 3 min read

How to Use DIVIDE Function in DAX for Power BI Calculations

Use the DIVIDE function in DAX to perform division safely by specifying a numerator and denominator. It automatically handles divide-by-zero cases by returning an alternate result you can define, preventing errors in your Power BI reports.
๐Ÿ“

Syntax

The DIVIDE function syntax is:

  • DIVIDE(numerator, denominator, [alternateResult])

numerator: The number to be divided.

denominator: The number to divide by.

alternateResult (optional): The value to return if the denominator is zero or blank. If omitted, it returns blank.

DAX
DIVIDE(<numerator>, <denominator>, [alternateResult])
๐Ÿ’ป

Example

This example calculates the sales per customer safely, avoiding errors if the number of customers is zero.

DAX
Sales Per Customer = DIVIDE(SUM(Sales[TotalSales]), SUM(Sales[CustomerCount]), 0)
Output
If TotalSales = 1000 and CustomerCount = 0, then Sales Per Customer = 0
โš ๏ธ

Common Pitfalls

Common mistakes include dividing directly with / which causes errors if the denominator is zero or blank. Also, forgetting to provide an alternateResult can lead to blank results that confuse report users.

Wrong way:

Sales Per Customer = SUM(Sales[TotalSales]) / SUM(Sales[CustomerCount])

This causes an error if CustomerCount is zero or blank.

Right way:

Sales Per Customer = DIVIDE(SUM(Sales[TotalSales]), SUM(Sales[CustomerCount]), 0)

This returns 0 instead of error.

๐Ÿ“Š

Quick Reference

ParameterDescriptionExample
numeratorValue to be dividedSUM(Sales[TotalSales])
denominatorValue to divide bySUM(Sales[CustomerCount])
alternateResultValue if denominator is zero or blank0 or BLANK()
โœ…

Key Takeaways

Use DIVIDE to safely perform division and avoid errors from zero or blank denominators.
Always provide an alternateResult to control what shows when division is not possible.
Avoid using the / operator directly in DAX when denominator might be zero or blank.
DIVIDE improves report reliability and user experience by handling divide-by-zero gracefully.