skip to content

In DAX, what does DIVIDE do that the / operator does not?

level: juniorimportance: should knowfreq 55%

answer

  1. one of them handles a zero denominator
  2. the other can print Infinity in a card
  3. there is an optional third argument
  4. blank rows are hidden by visuals, zeros are not

basics

~20 s

DIVIDE is DAX's safe division function: when the denominator is zero or blank it returns BLANK, or an alternate result you pass as the third argument. The / operator instead yields Infinity or NaN, which then leaks into the visual.

solid answer

~40 s

`DIVIDE(numerator, denominator, [alternateResult])` performs the divide-by-zero check internally. If the denominator is zero or blank, it returns BLANK by default, or whatever you pass as the optional third argument. The `/` operator has no such guard: a non-zero numerator over zero evaluates to Infinity, and 0/0 to NaN, and those values render in cards and matrices exactly as ugly as they sound. So a ratio measure is normally written `Margin % = DIVIDE([Profit], [Sales])` rather than `[Profit] / [Sales]`. BLANK is usually the right default because Power BI visuals hide blank rows and skip blank points, whereas a hard 0 would draw a real bar at zero and claim a value that was never measured. Use the third argument only when zero genuinely is the business answer.

code

dax · 8 lines
dax
-- unsafe: prints Infinity when Total Sales is 0 or blank
Margin % Unsafe = [Total Profit] / [Total Sales]

-- safe: blank when there is nothing to divide by
Margin % = DIVIDE ( [Total Profit], [Total Sales] )

-- safe, and 0 is the intended business answer here
Refund Rate = DIVIDE ( [Refunded Orders], [Total Orders], 0 )

go deeper

for a junior

Be ready to write a ratio measure with DIVIDE from memory and say what its third argument is for. Knowing that plain division can produce Infinity in a visual is the point being checked.

for a middle

Explain why BLANK rather than 0 is the default, and how Power BI visuals suppress blank rows and points. Be able to justify when you would override that with an alternate result.

for a senior

Show that you treat the zero-denominator path as a reporting decision: what the audience should see for a sparse category, and how that choice interacts with visual row suppression and chart axes.

for a principal

Own it as a convention question — a measure library where some ratios blank out and others return zero produces inconsistent reports, so the standard belongs in a written DAX style guide rather than in each author's habits.

## Why division needs a special function Almost every interesting DAX measure is a ratio: margin percentage, conversion rate, average order value, share of total. Each is one aggregate divided by another, and the denominator of an aggregate is frequently zero or blank — a product category with no sales in the sliced month, a salesperson with no visits, a segment that only exists in one year of the data. How the language handles that case decides what your report shows in the sparse corners of the model, which is exactly where readers look for trouble. ## What the / operator does DAX's `/` is arithmetic division and follows floating-point rules. A non-zero numerator divided by zero evaluates to Infinity; zero divided by zero evaluates to NaN. Neither raises an error that stops the report — they flow straight into the visual, so a card can literally display `Infinity` and a line chart can break at a NaN point. A blank denominator is coerced to zero in arithmetic, so `[Profit] / BLANK()` lands in the same trap. The failure is silent at author time and loud in front of the audience. ## What DIVIDE does `DIVIDE(numerator, denominator, [alternateResult])` wraps the same division in a guard. If the denominator is zero or blank, DIVIDE stops and returns the alternate result; when you omit that third argument, the alternate result is BLANK. Otherwise it returns the ordinary quotient. That is the whole contract, and it is why the idiomatic ratio measure looks like this: ``` Margin % = DIVIDE( [Total Profit], [Total Sales] ) ``` The function is not doing anything you could not write yourself with `IF ( [Total Sales] = 0, BLANK(), [Total Profit] / [Total Sales] )`. It is doing it in one expression that reviewers recognise instantly, and Microsoft's own guidance is to prefer DIVIDE over hand-rolled IF wrappers. ## Why BLANK is a better default than 0 BLANK in DAX means "no value here", and Power BI visuals treat it that way. A matrix row whose every measure is blank is hidden; a line chart does not plot a blank point; a card shows an empty value rather than a number. Returning 0 instead asserts something different and stronger: that the ratio was measured and came out at zero. On a margin-percentage chart that draws a real bar sitting on the axis, and a reader cannot tell it apart from a genuine zero-margin category. Reserve `DIVIDE(a, b, 0)` for the cases where zero is the business answer — a refund rate for a customer with no refunds is arguably 0%, a margin for a category with no sales is not. ## The third argument is a value, not a fallback formula The alternate result is evaluated as an expression, so it can be another measure, but it fires only on the zero/blank-denominator path. It is not a general error handler: DIVIDE does not rescue you from a type mismatch or from a numerator that is itself wrong. It handles precisely one condition. ## Blank numerators behave differently If the numerator is blank and the denominator is a real number, DIVIDE returns BLANK — blank coerces to zero, and zero over something is zero, which DAX surfaces as blank in most measure contexts. People sometimes expect a zero here and a blank there and get confused; the rule to remember is that the guard is on the denominator only. ## When plain / is still fine Inside an iterator where you have already filtered to rows with a positive denominator, or when dividing by a hard-coded constant such as `/ 1000` for a thousands scale, the operator is perfectly readable and there is nothing to guard. The habit worth forming is: any division whose denominator is a measure or a column value gets DIVIDE; any division by a literal you control does not need it. ## What interviewers listen for They want to hear the three-part answer — safe divide-by-zero, optional alternate result, BLANK by default — and then the judgment layer: that BLANK is chosen deliberately because visuals suppress it, and that returning 0 is a reporting decision rather than a defensive reflex. Candidates who answer only "it avoids errors" have used the function without thinking about what the report then shows.

  • When would you pass 0 as DIVIDE's third argument instead of letting it return BLANK?
    When zero is the true business answer and the row should still appear. A refund rate for a customer with orders but no refunds is genuinely 0%, and hiding that row would misrepresent the customer. A margin percentage for a category with no sales at all is not zero — it is unknown — so that one should stay blank and let the visual drop the row.
  • Does DIVIDE protect you when the numerator is blank rather than the denominator?
    No. The guard is on the denominator only. A blank numerator coerces to zero, so the quotient is zero and typically surfaces as blank in the visual anyway, but that is ordinary DAX blank arithmetic rather than anything DIVIDE did. If a blank numerator should read as something specific, handle it explicitly with an IF or COALESCE around the numerator.

saying these in an interview costs you the question

  • Claiming the / operator throws an error on divide by zero
  • Wrapping every division in IFERROR-style logic instead of DIVIDE
  • Returning 0 by default because blank looks broken
  • Thinking DIVIDE guards the numerator as well
  • Believing DIVIDE catches any calculation error, not just zero denominators

context