All DAX Functions

The DIVIDE() Function: Safe Division and Error Handling

Divide safely without division-by-zero errors in visuals.

On this page

Overview

The DIVIDE function performs safe division in DAX. Unlike the / operator, it lets you specify an alternate result when the denominator is zero or blank, preventing errors and unwanted BLANK() propagation in visuals.

It is the standard choice for ratio and rate measures—cost per lead, conversion rate, average order value—where empty or zero denominators are common in real data.

Syntax

DAX Syntax
DIVIDE(<numerator>, <denominator> [, <alternateResult>])
  • <numerator>: The value to divide (e.g., total spend).
  • <denominator>: The divisor (e.g., lead count).
  • <alternateResult> (optional): Returned when denominator is zero or blank; defaults to BLANK() if omitted.

Example & Dataset

A marketing Campaigns table tracks spend and leads generated per campaign:

Sample Data Table: Campaigns

CampaignIDCampaignNameSpendLeads
CMP01Spring Email5000250
CMP02Social Ads30000
CMP03Webinar150075

The DAX Code

To calculate cost per lead for each campaign—and show 0 instead of an error when no leads were recorded—use DIVIDE with an alternate result:

Cost Per Lead Measure
Cost Per Lead =
DIVIDE(
    SUM(Campaigns[Spend]),
    SUM(Campaigns[Leads]),
    0
)

Expected Output Visual

In a Table visual with CampaignName and [Cost Per Lead]:

Output Table Visual

CampaignNameSpendLeadsCost Per Lead
Spring Email500025020.00
Social Ads300000
Webinar15007520.00

Why Did This Output Happen?

DIVIDE(5000, 250) = 20 for Spring Email. For Social Ads the denominator is 0; DIVIDE returns the alternate result 0 instead of an error or infinity. Webinar: 1500 ÷ 75 = 20. Using / would force you to wrap logic in IF; DIVIDE handles the edge case in one readable function.