Information
Checks whether a value is blank, and returns TRUE or FALSE
ISBLANK(<value>)
ISBLANK Function in DAX - Comprehensive Guide with Contoso Data
Function Overview
ISBLANK is a logical DAX function that checks whether a value is blank (empty/null) and returns TRUE if the value is blank or FALSE if it contains any value. This function is essential for error handling, data validation, and creating robust measures that won't break when encountering missing data.
Applies to:
- ✅ Calculated columns
- ✅ Calculated tables
- ✅ Measures
- ✅ Visual calculations
Syntax
ISBLANK(<value>)Parameters
Parameter | Definition |
value | The value or expression you want to test. This can be a column reference, a measure, or any DAX expression that returns a value. |
Return Value
Returns a Boolean value:
TRUEif the value is blank/null/emptyFALSEif the value contains any data (including zero, empty text "", or any other value)
Why ISBLANK Matters: The Divide by Zero Problem
In business analytics, one of the most common scenarios where ISBLANK becomes essential is calculating growth rates, percentage changes, or ratios. When you divide by a previous period's value that doesn't exist (for example, comparing 2023 sales to 2022 sales when your business started in 2023), you encounter a divide-by-zero error that can break your entire report.
ISBLANK allows you to detect these situations before they cause errors and handle them gracefully.
Practical Example: Year-over-Year Sales Growth with Contoso Data
Business Scenario
You are analyzing sales performance for Contoso, a fictional retail company. The executive team wants to see the sales growth rate compared to the previous year for each year of operation. However, the first year of business (2007) has no prior year to compare against, which would create a divide-by-zero error. You need to handle this situation elegantly using ISBLANK.
The Contoso Database Context
For this example, we're working with:
- FactSales table: Contains transaction-level sales data with columns including SalesAmount and DateKey
- DimDate table: Contains date information with Year, Month, Quarter attributes
- Your sales data spans from 2007 through 2009
Step 1: Create a Measure for Current Year Total Sales
First, let's create a straightforward measure that calculates total sales for whatever year is in context.
Total Sales = SUM(FactSales[SalesAmount])Explanation: This measure simply sums all SalesAmount values from the FactSales table. When you use this measure in a visual filtered by year, it will automatically show only that year's sales due to filter context.
Step 2: Create a Measure for Previous Year Total Sales
Next, we need a measure that calculates sales for the previous year. We use the CALCULATE function combined with SAMEPERIODLASTYEAR to shift the date context back by one year.
Previous Year Total Sales =
CALCULATE(
SUM(FactSales[SalesAmount]),
SAMEPERIODLASTYEAR(DimDate[DateKey])
)
Detailed Explanation:
CALCULATE( - This function evaluates an expression in a modified filter context
- First parameter:
SUM(FactSales[SalesAmount])- what to calculate - Second parameter:
SAMEPERIODLASTYEAR(DimDate[DateKey])- how to modify the filter context
SAMEPERIODLASTYEAR(DimDate[DateKey]) - Returns dates from the same period in the previous year
- For example, if the current context is 2008, this function returns all dates from 2007
- If the current context is 2007 (the first year), this function returns BLANK because there is no 2006 data
Important behavior: When SAMEPERIODLASTYEAR finds no matching prior year dates (like in 2007, the first year of business), it returns BLANK. Consequently, the entire measure returns BLANK for that year.
Step 3: Create the Year-over-Year Growth Rate Measure with ISBLANK Protection
Now we create the critical measure that calculates the growth percentage while protecting against the divide-by-zero error using ISBLANK.
Sales Growth % vs Previous Year =
IF(
ISBLANK([Previous Year Total Sales]),
BLANK(),
DIVIDE(
[Total Sales] - [Previous Year Total Sales],
[Previous Year Total Sales]
)
)
Detailed Step-by-Step Breakdown:
1. IF( ... ) - Conditional logic function with three parameters:
- Condition to test
- Value if TRUE
- Value if FALSE
2. ISBLANK([Previous Year Total Sales]) - The condition being tested
- Checks whether the Previous Year Total Sales measure returned BLANK
- Returns TRUE if blank (meaning no prior year data exists)
- Returns FALSE if the measure has a value
3. BLANK() - The value to return if the condition is TRUE
- Returns a blank value instead of attempting the division
- This prevents the #ERROR or division by zero issue
- In visuals, BLANK typically displays as empty cells or dashes
4. DIVIDE([Total Sales] - [Previous Year Total Sales], [Previous Year Total Sales]) - The value to return if the condition is FALSE
- This is the actual growth calculation
- Numerator:
[Total Sales] - [Previous Year Total Sales]calculates the absolute change - Denominator:
[Previous Year Total Sales]provides the base for percentage calculation - DIVIDE function automatically handles division and includes built-in divide-by-zero protection (though ISBLANK already handles this scenario)
How It Works: Execution Flow for Each Year
For Year 2007 (First Year):
- Total Sales = $9,927,582.99
- Previous Year Total Sales = BLANK (no 2006 data exists)
- ISBLANK([Previous Year Total Sales]) evaluates to TRUE
- The IF function returns BLANK()
- Result: Sales Growth % vs Previous Year shows BLANK
For Year 2008:
- Total Sales = $9,770,899.74
- Previous Year Total Sales = $9,927,582.99
- ISBLANK([Previous Year Total Sales]) evaluates to FALSE (has a value)
- The IF function proceeds to the DIVIDE calculation:
- Numerator: $9,770,899.74 - $9,927,582.99 = -$156,683.25
- Denominator: $9,927,582.99
- Result: -$156,683.25 / $9,927,582.99 = -0.01578 = 1.58%
For Year 2009:
- Total Sales = $9,353,814.87
- Previous Year Total Sales = $9,770,899.74
- ISBLANK([Previous Year Total Sales]) evaluates to FALSE
- The IF function proceeds to the DIVIDE calculation:
- Numerator: $9,353,814.87 - $9,770,899.74 = -$417,084.87
- Denominator: $9,770,899.74
- Result: -$417,084.87 / $9,770,899.74 = -0.04268 = 4.27%
Example Output Table with Contoso Data
Year | Total Sales | Previous Year Total Sales | Sales Growth % vs Previous Year |
2007 | $9,927,582.99 | - | - |
2008 | $9,770,899.74 | $9,927,582.99 | -1.58% |
2009 | $9,353,814.87 | $9,770,899.74 | -4.27% |
Grand Total | $29,052,297.60 |
Business Interpretation
The results tell a concerning story for Contoso:
- 2007: The baseline year with approximately $9.9M in sales
- 2008: Sales declined by 1.58%, losing about $157K compared to 2007
- 2009: Sales declined further by 4.27%, losing about $417K compared to 2008
The ISBLANK protection ensures that the 2007 row displays cleanly without errors, making the report professional and user-friendly. Without ISBLANK, the report would show an error in the 2007 row, confusing stakeholders and potentially causing the entire visual to fail.
Alternative Formulation Using Nested IF
You might also see this pattern written without ISBLANK, using the fact that DIVIDE returns BLANK when the denominator is BLANK:
Sales Growth % vs Previous Year =
IF(
[Previous Year Total Sales] = BLANK(),
BLANK(),
DIVIDE(
[Total Sales] - [Previous Year Total Sales],
[Previous Year Total Sales]
)
)
However, ISBLANK is the preferred and more explicit approach because:
- It's more readable and clearly states the intent
- It's a dedicated function designed specifically for this purpose
- It follows DAX best practices for blank handling
Important Remarks: Understanding BLANKs in DAX
What qualifies as BLANK?
- Null values from the data source
- Missing data or empty cells
- Results from functions that return no value (like SAMEPERIODLASTYEAR when there's no prior period)
- Explicitly set BLANK() values
What does NOT qualify as BLANK?
- The number zero (0)
- Empty text strings ("")
- Whitespace characters
Best Practice: According to Microsoft's DAX guidelines, you should avoid converting BLANKs to other values (like zero) unless there's a specific business requirement. BLANKs provide meaningful information—they indicate the absence of data, which is different from zero, which indicates a measured value of nothing.
For example:
- BLANK sales for 2006 = "We didn't exist in 2006"
- $0 sales for 2006 = "We were in business in 2006 but sold nothing"
These are fundamentally different business situations that should be represented differently.
Additional Practical Use Cases with Contoso
Use Case 1: Product Performance Analysis
Product Sales Growth =
IF(
ISBLANK([Previous Month Sales]),
BLANK(),
DIVIDE([Current Month Sales] - [Previous Month Sales], [Previous Month Sales])
)
Use this when analyzing individual product performance where new products won't have prior month sales.
Use Case 2: Store Opening Analysis
Days Since Store Opening =
IF(
ISBLANK(DimStore[OpenDate]),
"Opening date not recorded",
DATEDIFF(DimStore[OpenDate], TODAY(), DAY) & " days"
)
Use this to handle stores in your dataset that might not have opening dates recorded.
Use Case 3: Customer Lifetime Value Protection
Customer Lifetime Value =
IF(
ISBLANK([First Purchase Date]),
"No purchases recorded",
CALCULATE(SUM(FactSales[SalesAmount]), ALLEXCEPT(DimCustomer, DimCustomer[CustomerKey]))
)
Use this when calculating metrics for customers who might exist in your system but haven't made purchases yet.
Summary
The ISBLANK function is an essential tool in your DAX arsenal for creating professional, error-free reports. When working with time-based comparisons, new products, new stores, or any scenario where data might not exist for all records, ISBLANK provides the protection needed to handle these situations gracefully. By combining ISBLANK with IF and DIVIDE functions, you can create robust measures that provide accurate business insights without breaking when encountering missing data.