BLANK in DAX: how blanks behave and how to handle them

How BLANK works in DAX, the arithmetic and logic rules (BLANK + 5 is 5, BLANK * 5 is BLANK, 5 / BLANK is infinity), comparisons with 0 and empty text, ISBLANK, COALESCE and DIVIDE, why visuals hide blank rows, and why turning blanks into zeros hurts.

Short answer: BLANK is DAX's empty value, the equivalent of SQL's NULL. It follows its own rules: BLANK + 5 is 5, but BLANK * 5 is BLANK; 5 / BLANK is infinity; BLANK = 0 and BLANK = "" are both TRUE. Visuals hide rows where every measure is BLANK, which is usually what you want. Test with ISBLANK, replace with COALESCE, divide with DIVIDE, and do not turn every blank into 0: it fills visuals with empty rows and slows them down.

A measure that returns 0 instead of BLANK for products that never sold makes a table of 40 products show 4,000 rows, one per product and customer, most of them zero. Knowing when DAX produces BLANK, and when to keep it, decides both the numbers and the speed of a report.

How does BLANK behave in arithmetic and logic?

ExpressionDAXExcel
BLANK + BLANKBLANK0
BLANK + 555
BLANK * 5BLANK0
5 / BLANKInfinityError
0 / BLANKNaNError
BLANK / BLANKBLANKError
FALSE OR BLANKFALSEFALSE
FALSE AND BLANKFALSEFALSE
TRUE OR BLANKTRUETRUE
TRUE AND BLANKFALSETRUE
BLANK OR BLANKBLANKError
BLANK AND BLANKBLANKError
Microsoft's table of BLANK in DAX against Excel

In comparisons, BLANK is converted to 0, "" or FALSE, depending on the other value. So BLANK() = 0 is TRUE. To tell blank from zero, use ISBLANK or the strict operator ==: BLANK() == 0 is FALSE.

Where do blanks come from?

  • A measure over no rows: SUM ( Sales[Amount] ) for a product with no sales returns BLANK, not 0.
  • Empty source values: nulls from the source become BLANK.
  • Missing relationship matches: a sales row whose product key is not in the Product table goes to a blank row on the one side.
  • Functions that find nothing: SELECTEDVALUE with several values and no alternate result, LOOKUPVALUE with no match, DIVIDE by zero.

How do you test and replace blanks?

-- test
Has Sales = NOT ISBLANK ( [Revenue] )

-- replace, only where a 0 means something
Revenue or Zero = COALESCE ( [Revenue], 0 )

-- divide safely: BLANK (or an alternate) when the denominator is 0 or BLANK
Margin % = DIVIDE ( [Margin], [Revenue] )

-- compare to last year only when last year exists
Revenue vs LY =
VAR LY = [Revenue LY]
RETURN IF ( NOT ISBLANK ( LY ), [Revenue] - LY )

COALESCE returns the first argument that is not BLANK; it takes two or more arguments.

Why not turn every blank into zero?

Microsoft's guidance "Avoid converting BLANKs to values" explains it: visuals drop rows where all measures are BLANK. A measure like [Revenue] + 0 or IF ( ISBLANK ( [Revenue] ), 0, [Revenue] ) returns a value for every combination of the visual's fields, so a table of products by customers lists every pair, most with 0. The result is long, slow and hard to read.

-- keeps blank rows out of visuals
Revenue = SUM ( Sales[Amount] )

-- turns every product-customer pair into a row
Revenue Zero = SUM ( Sales[Amount] ) + 0

Use zeros only where the reader needs to see "nothing sold" for a known list (for example on a card, or months in a line chart where a gap would mislead), and keep the zero-version for that visual only.

How do you show the blank row?

When the many side has keys not found on the one side, visuals show a (Blank) item: sales without a known product. Count them:

Sales Without Product =
CALCULATE ( COUNTROWS ( Sales ), ISBLANK ( RELATED ( 'Product'[Product Key] ) ) )

A simpler check: filter a visual on 'Product'[Product] is blank. Fix the keys in the source rather than hiding the row.

What goes wrong?

  • = 0 tests. IF ( [Revenue] = 0, ... ) is also TRUE for BLANK; use ISBLANK or == when the difference matters.
  • Averages over zeros. Turning blanks into zeros lowers averages; AVERAGE skips blanks.
  • Division with /. [A] / [B] gives infinity or an error; use DIVIDE.
  • Blank text. "" and BLANK look alike in a visual; ISBLANK ( "" ) is FALSE.

Where can you check this?

Where do you start?

Search your measures for + 0 and IF ( ISBLANK ( ... ), 0 and remove the ones that only fill visuals with zeros. DIVIDE in DAX covers safe division.

Keep reading

More from the blog.

Every post

Next

Building this? Say hello.

A question about this post, a pattern you would build differently, or the next thing you want written out: Behnia reads every message.