How to Calculate Date Difference in Power BI

Cody Schneider8 min read

Calculating the time between two dates is a cornerstone of business analysis, and Power BI makes this task straightforward once you know the right tools. Whether you’re trying to figure out your average sales cycle, shipping times, or employee tenure, understanding date difference calculations is a must-have skill. This guide will walk you through exactly how to do it using DAX, Power BI’s formula language.

Why Calculating Date Differences Matters

Before jumping into the formulas, it’s helpful to understand why this is so important. Measuring duration helps you uncover critical insights about your business operations. You might be tracking:

  • Sales Cycle Length: The time from a lead’s first contact to when the deal is closed.
  • Project Duration: How long projects take from start to finish.
  • Customer Service Resolution Time: How quickly you resolve support tickets.
  • Shipping or Delivery Time: The duration between an order being placed and the customer receiving it.
  • Employee Tenure: How long an employee has been with the company.
  • Age of Inventory: How long items have been sitting in your warehouse.

In all these cases, you’re measuring the gap between a start date and an end date. Getting this right is the first step toward optimizing your processes.

The Main Tool for the Job: DATEDIFF

The primary function you'll use in Power BI for date calculations is DATEDIFF. It’s a versatile and powerful DAX function that does exactly what its name suggests: calculates the difference between two dates.

The syntax is simple:

DATEDIFF(<start_date>, <end_date>, <interval>)

Let’s break that down:

  • <start_date>: The first date in your calculation (e.g., an OrderDate).
  • <end_date>: The second date in your calculation (e.g., a ShipDate).
  • <interval>: The unit of time you want the result to be in.

For the interval, you have several options:

  • SECOND
  • MINUTE
  • HOUR
  • DAY
  • WEEK
  • MONTH
  • QUARTER
  • YEAR

Now, let's put this into practice with a few common scenarios.

Scenario 1: Finding the Difference Between Two Date Columns

This is the most common use case. Imagine you have a table named Orders with a column for OrderDate and another for ShipDate. You want to create a new column, ShippingTimeDays, that shows how many days it took to ship each order.

Step-by-Step Instructions

1. Navigate to your data view: In Power BI Desktop, click on the Data view icon on the left-hand sidebar (the little grid icon).

2. Select your table: Find and select your Orders table from the Fields pane on the right.

3. Create a new calculated column: Go to the "Table tools" tab in the ribbon at the top of the screen and click "New column". This will open up the formula bar where you can enter your DAX expression.

4. Enter the DATEDIFF formula: In the formula bar, type the following DAX formula and press Enter:

ShippingTimeDays = DATEDIFF(Orders[OrderDate], Orders[ShipDate], DAY)

Power BI will now calculate the difference for each row in your table and populate the ShippingTimeDays column with the result in days.

Calculating in Different Units

What if you wanted to see the result differently? It’s as easy as changing the interval.

For shipping time in weeks, you’d use:

ShippingTimeWeeks = DATEDIFF(Orders[OrderDate], Orders[ShipDate], WEEK)

For the number of months (though less common for shipping), you might use:

ShippingTimeMonths = DATEDIFF(Orders[OrderDate], Orders[ShipDate], MONTH)

Scenario 2: Calculating Duration from a Start Date to Today

Another popular use case is calculating the elapsed time from a specific start date up to the current date. For example, how long has a project been active? Or how old is a specific invoice? For this, you’ll need a function that always returns today’s date: TODAY().

Using DATEDIFF with TODAY()

Let's say you have an Employees table with a HireDate column. You want to calculate the tenure of each employee in years.

1. Create a new calculated column in your Employees table as you did in the previous example.

2. Enter the formula using TODAY(): In the formula bar, type:

TenureYears = DATEDIFF(Employees[HireDate], TODAY(), YEAR)

This will create a column that shows the number of full years each employee has worked at the company. This number will automatically update every time you refresh your report because TODAY() always provides the current date of the refresh.

Similarly, to find the age of a support ticket in days from a Tickets table:

TicketAgeDays = DATEDIFF(Tickets[CreatedDate], TODAY(), DAY)

Calculated Columns vs. Measures: What's the Difference?

So far, we’ve only created calculated columns. But in Power BI, you can also perform calculations using measures. Understanding the distinction is important for building efficient and scalable reports.

Calculated Columns

  • A calculated column adds a new column to your table. The calculation is performed once for each row during data refresh and the results are stored in your data model.
  • Pros: The results are pre-calculated, so they are fast to use in visuals, slicers, or filters. They are best when you need to see a result on a row-by-row basis. Our ShippingTimeDays is a perfect example.
  • Cons: They increase the file size of your report and consume RAM because the values for every single row are stored.

Measures

  • A measure is a calculation that is performed on-the-fly, at the time you use it in a visual. It doesn't create a new column or store any data in your model. It returns a single, aggregated value based on the context of your report (e.g., filters applied).
  • Pros: They don’t increase file size and are ideal for summary values like totals, averages, or counts that need to react to user selections.
  • Cons: Because they're calculated at query time, complex measures can sometimes feel slightly slower in reports interacting with massive datasets.

When to Use a Measure for Date Differences

Let's go back to our shipping time example. Creating ShippingTimeDays as a calculated column is great for seeing individual order durations. But what if you just wanted to show the average shipping time in a card visual?

For that, a measure is a much better choice.

1. Go to the "Modeling" tab and click "New Measure."

2. Enter this DAX formula:

Average Shipping Time = 
AVERAGEX(
    Orders,
    DATEDIFF(Orders[OrderDate], Orders[ShipDate], DAY)
)

This measure iterates through the Orders table (AVERAGEX), calculates the DATEDIFF in days for each row, and then finds the average. You can now drag this measure onto a card visual, and it will show you the overall average shipping time. Better yet, if you create a chart with "Average Shipping Time" by "Product Category," the measure will automatically recalculate the average for each category.

Handling Common Problems and Edge Cases

Real-world data is rarely perfect. Here’s how to handle a couple of common issues you might face.

Dealing with Blanks or Missing Dates

What happens if an order hasn't shipped yet, making the ShipDate blank? DATEDIFF will return an error because it can't calculate with a null value.

You can wrap your DAX in an IF statement to check for blanks first.

Here’s the ShippingTimeDays calculated column, now more robust:

ShippingTimeDays =

IF(

ISBLANK(Orders[ShipDate]),

BLANK(),

DATEDIFF(Orders[OrderDate], Orders[ShipDate], DAY)

)

This formula checks if Orders[ShipDate] is blank. If it is, it returns BLANK(). Otherwise, it calculates the date difference as normal. This prevents your calculations from breaking.

Sorting Out Date vs. DateTime Issues

Sometimes you’ll have one column formatted as a date (e.g., 4/15/2024) and another as a datetime (e.g., 4/18/2024 10:30 AM). DATEDIFF with the DAY interval will still work correctly, but it uses the full datetime value, which might yield fractional results you don't expect when using smaller intervals like HOUR or MINUTE.

If you only care about the date part, it's a good practice to ensure both columns are formatted as the Date data type in the Power Query Editor before you even get to DAX. This consistency prevents unexpected behavior down the road.

Final Thoughts

You’ve now learned how to use the versatile DATEDIFF function to calculate the time between two points in Power BI. We've covered calculating durations between two columns, from a past date to today, and the critical difference between using calculated columns for row-level details and measures for aggregated insights.

Mastering DAX functions like this is essential, but it’s often just one of many steps in a long reporting process. Manually pulling data from different places, cleaning it, and then spending hours writing formulas can drain your time and energy. With Graphed, we connect directly to your marketing and sales data sources (like Google Analytics, Salesforce, or Shopify) and let you build reports just by asking questions. Instead of writing DAX, you can simply ask, "Show me the average shipping time by product category last quarter," and get an interactive dashboard in seconds.

Related Articles

How to Connect Facebook to Google Data Studio: The Complete Guide for 2026

Connecting Facebook Ads to Google Data Studio (now called Looker Studio) has become essential for digital marketers who want to create comprehensive, visually appealing reports that go beyond the basic analytics provided by Facebook's native Ads Manager. If you're struggling with fragmented reporting across multiple platforms or spending too much time manually exporting data, this guide will show you exactly how to streamline your Facebook advertising analytics.

Appsflyer vs Mixpanel​: Complete 2026 Comparison Guide

The difference between AppsFlyer and Mixpanel isn't just about features—it's about understanding two fundamentally different approaches to data that can make or break your growth strategy. One tracks how users find you, the other reveals what they do once they arrive. Most companies need insights from both worlds, but knowing where to start can save you months of implementation headaches and thousands in wasted budget.