Ravindra BagaleCourses & study guides मराठी Track your progress

13. DAX: Data Analysis Expressions

13.19 Other Useful Functions

COALESCE and ISBLANK in DAX with example — in 30 seconds

What: COALESCE returns the first value that is not blank. ISBLANK tells you if a value is blank.

Why: Kolhapur had no orders last year. Its "Sales LY" cell is empty, and the manager thinks the report is broken.

Tiny example: Sales LY for Kolhapur is blank. COALESCE([Sales LY], 0) shows ₹0, and a status measure says "New".

First look at the data (before → after):

COALESCE and ISBLANK in DAX with example: before and after tables, fictional Blinkit Maharashtra data

Same before / after tables as text

Before — Matrix by city (one blank cell)

City Total Sales Sales LY
Pune ₹1,200 ₹1,000
Nashik ₹300 ₹250
Kolhapur ₹150 (blank)

About this data: This table uses columns: City, Total Sales, Sales LY. This table uses columns: City, Total Sales, Sales LY (0), City Status. This table uses columns: Function, Purpose, Example. Values shown are the lesson examples already on this page (not a new dataset).

Formula / click path

Sales LY (0) = COALESCE([Sales LY], 0)
City Status  = IF(ISBLANK([Sales LY]), "New", "Existing")

After — After COALESCE and ISBLANK

City Total Sales Sales LY (0) City Status
Pune ₹1,200 ₹1,000 Existing
Nashik ₹300 ₹250 Existing
Kolhapur ₹150 ₹0 New

Do it step by step:

  1. Make sure [Sales LY] exists (section 13.16).
  2. Click Home › New measure. Type Sales LY (0) = COALESCE([Sales LY], 0).
  3. Click New measure again. Type the City Status formula.
  4. Build a matrix. Rows = DarkStore[City]. Add the three measures.
  5. Check Kolhapur: ₹0 and "New".
  6. Do not add + 0 to every measure. Use COALESCE only where zero has a real meaning.
Function Purpose Example
ISBLANK Tests for blank IF(ISBLANK([Sales LY]), "New", "Existing")
COALESCE First non-blank value COALESCE([Total Sales], 0)
BLANK() Returns blank IF([Total Orders] = 0, BLANK(), [Total Orders])
SUMMARIZE Group-by table SUMMARIZE(Orders, DarkStore[City])
ADDCOLUMNS Adds calculated columns to a table expression see Top 10 Stores above
CALCULATETABLE CALCULATE that returns a table CALCULATETABLE(Orders, 'Date'[Year] = 2025)
CROSSFILTER Changes relationship direction for one calculation CALCULATE([Total Orders], CROSSFILTER(Orders[Customer ID], Customer[Customer ID], BOTH))
ISINSCOPE TRUE when a column is the current level in a hierarchy used for level-specific measures in matrices
ROUND Rounds a number ROUND([Avg Delivery Time (mins)], 1)

DAX formatting tip

Keep one argument per line for long formulas, indent nested functions, and give measures clear names such as Sales LY or Cancellation Rate. Free online formatters such as DAX Formatter by SQLBI can tidy your code automatically.

Ravindra Bagale's Tip

Friends, many students forget blank handling and get confusing results when they combine functions like COALESCE, ISBLANK and "+ 0". Adding 0 to a measure shows zeros for every combination and can explode the size of a table visual. Use it only where zero really has meaning. This matters for both exams and interviews.

Loading DAX practice tasks...

  1. Rounded order value (Easy): Measure: AOV Rounded = [Total Sales] ÷ [Total Orders], rounded to 0 decimals.
  2. Whole minutes (Easy): Measure: Avg Mins Whole = the average DeliveryMins with decimals cut off.
  3. Margin per product (Easy): Calculated column on Product: Margin = MRP − CostPrice.
  4. Even quantity flag (Medium): Calculated column on Orders: Even Qty = TRUE when Qty is even.
  5. Show 0 not blank (Medium): Slicer: Platform = Zepto. Shown per Store City. Measure: Sales or 0 = [Total Sales], or 0 when blank.
  6. Has sales? (Medium): Slicer: Platform = Zepto. Shown per Store City. Measure: Sales Status = "No sales" if [Total Sales] is blank, else "Has sales".
  7. Sales as text (Medium): Measure: Sales Text = [Total Sales] formatted with the pattern "#,0".
  8. Discount rate rounded (Hard): Measure: Disc Rate = SUM of Discount ÷ [Total Sales], rounded to 3 decimals.
  9. Speed band per city (Hard): Shown per Store City. Measure: Speed = "Fast" if average DeliveryMins ≤ 15, "OK" if ≤ 25, else "Slow".
  10. Category list (Hard): Measure: Categories = all different Product Category values joined with ", " in A to Z order.

Ravi Sir's Cards for this lesson

मराठी cards