How to Count Days in Power BI

Cody Schneider8 min read

Calculating the number of days between two dates is a fundamental task in data analysis, but it can feel tricky when you're getting started with Power BI. Whether you need to find the duration of a project, the age of an invoice, or the total business days in a month, Power BI has you covered. This post will walk you through several common scenarios for counting days using DAX, Power BI's powerful formula language.

Why Counting Days Is So Important

Before jumping into the formulas, let's consider a few places where counting days can provide valuable business insights:

  • Sales & Operations: How long does it take from when an order is placed to when it's shipped? Calculating the "days to ship" can help you identify bottlenecks in your fulfillment process.
  • Project Management: How long has a project been active? Tracking the days since a project's start date helps in monitoring progress against timelines.
  • Customer Service: What's the average age of an open support ticket? This metric is crucial for ensuring timely customer responses and managing team workload.
  • Finance: How many days overdue are your accounts receivable? Calculating invoice age helps manage cash flow and prioritize collections.

Each of these questions can be answered by counting days in a specific way, and Power BI DAX formulas give you the flexibility to do it all.

The Foundation: Understanding DAX and Date Tables

To perform any calculation in Power BI, you'll need to use DAX (Data Analysis Expressions). If you're coming from Excel, you can think of DAX as a supercharged version of Excel formulas. We'll be using a few key DAX functions to count days.

Equally important is the concept of a Date Table. For any serious analysis involving time, Power BI best practice is to have a dedicated calendar table in your data model. This is a separate table that contains a continuous list of dates, along with helpful columns like Day of Week, Month, Quarter, and Year. A date table acts as a reliable calendar for all your time-based calculations and is essential for some of the more advanced techniques we'll cover later.

Now, let's get into the practical, step-by-step methods for different day-counting scenarios.

Scenario 1: Counting the Total Days in a Selected Period

Sometimes you just need to know the total number of days within a given filter context, like a month or a quarter selected in a slicer. This is the simplest day-counting operation.

The Goal: Create a measure in a card visual that shows how many calendar days are in the period visible in your report.

The DAX Function: COUNTROWS()

This function simply counts the number of rows in a table. When you apply it to your date table, it will count the number of days based on your current filters.

Step-by-Step Instructions:

  1. Make sure you have a dedicated Date Table in your data model.
  2. In the Report view, right-click on your Date Table in the Data pane and select New Measure.
  3. Enter the following DAX formula in the formula bar:
  4. Press Enter to save the measure. You can now drag this measure into a card visual to display the total day count.

When you select "January" in a slicer, this measure will show 31. If you select Q1, it will show 90 (or 91 in a leap year). It dynamically responds to any date filters on your report page.

Scenario 2: Calculating Days Between Two Dates (Duration)

This is arguably the most common requirement: finding the duration between a start date and an end date. This is perfect for calculating things like shipping times, project lengths, or delivery lead times.

The Goal: Create a new column in a table that calculates the number of days between the values in two other date columns.

The DAX Function: DATEDIFF()

The DATEDIFF() function is specifically designed to find the difference between two dates and express it in a specific interval (days, months, years, etc.).

Step-by-Step Instructions:

Let's imagine you have a sales table named 'Orders' with a column for [OrderDate] and another for [ShipDate].

  1. Navigate to the Data view in Power BI and select your 'Orders' table.
  2. In the ribbon at the top, select New Column under the "Table tools" tab.
  3. Enter this formula into the formula bar:
  4. Press Enter. Power BI will add a new column to your table, calculating the days to ship for every single order.

Breaking Down the DATEDIFF Formula

The DATEDIFF function takes three arguments:

  • Date1: The start date (Orders[OrderDate] in our case).
  • Date2: The end date (Orders[ShipDate]).
  • Interval: The unit you want the result in. We used DAY, but you could also use MONTH, QUARTER, YEAR, HOUR, MINUTE, or SECOND.

A Quick Tip: What if an order hasn't shipped yet and the [ShipDate] is blank? The formula will produce an error. You can wrap it in an IF statement to gracefully handle blanks:

Days to Ship =
IF(
    ISBLANK(Orders[ShipDate]),
    BLANK(),
    DATEDIFF(Orders[OrderDate], Orders[ShipDate], DAY)
)

Scenario 3: Counting Days from a Past Date Until Today

This is extremely useful for tracking the age of "open" items. How long has a support ticket been open? How old is a sales lead? How many days late is an invoice?

The Goal: Create a dynamic column that calculates the number of days from a start date up to the current date.

The DAX Functions: DATEDIFF() and TODAY()

We'll combine our friend DATEDIFF with TODAY(), a function that returns the current date.

Step-by-Step Instructions:

Imagine a table of 'Support Tickets' with a [CreatedDate] column.

  1. In the Data view, select your 'Support Tickets' table.
  2. Click New Column.
  3. Use the following DAX formula:
  4. Press Enter. You now have a column that shows the current age of every ticket.

The best part about using TODAY() is that this calculation updates automatically every time you refresh your dataset. A ticket created yesterday will show an age of 1 today and 2 tomorrow.

Scenario 4: Counting Only Business Days (Excluding Weekends)

In many business contexts, "days" really means "work days." Calculating an order's shipping time in business days gives a more accurate picture of your operational efficiency than using calendar days.

The Goal: Calculate the number of weekdays (Monday-Friday) between two dates.

The DAX Approach: Iterating through a Date Table with COUNTROWS and FILTER.

Unlike Excel, Power BI DAX doesn't have a simple NETWORKDAYS function built-in. But we can easily build our own using the power of a good Date Table!

Step-by-Step Instructions:

First, ensure your Date Table has a weekday column. You can easily add one with a calculated column using the WEEKDAY() function. For example, Weekday = WEEKDAY('Date Table'[Date], 2) returns 1 for Monday through 7 for Sunday.

Now, let's create a calculated column in our 'Orders' table to find the business days between [OrderDate] and [ShipDate].

  1. Select your 'Orders' table in the Data view and click New Column.
  2. Enter this formula:
  3. Press Enter to create the column.

How This Formula Works

This formula might look complex, but it's very logical:

  1. FILTER('Date Table', ...): We start by telling Power BI we want to look at our Date Table.
  2. 'Date Table'[Date] >= Orders[OrderDate] && 'Date Table'[Date] <= Orders[ShipDate]: This finds all rows in our Date Table that fall between the order date and ship date for the specific order we are calculating.
  3. 'Date Table'[Weekday] < 6: This adds another filter, keeping only the days where our Weekday column is less than 6 (i.e., days 1 through 5, or Monday through Friday).
  4. COUNTROWS(...): Finally, we simply count how many rows are left in our filtered table. This gives us the total number of work days.

This pattern is incredibly powerful and demonstrates why having a dedicated Date Table is so invaluable in Power BI.

Final Thoughts

You've now seen how to handle a variety of day-counting scenarios in Power BI, from simple calendar counting to calculating complex business day durations. By choosing the right DAX functions like COUNTROWS and DATEDIFF and using best practices like a dedicated date table, you can accurately answer almost any time-based question your business has.

While mastering DAX is a powerful skill, we know it involves a learning curve and can still feel like manual work. We built Graphed to remove this friction entirely. Instead of writing and debugging DAX formulas and building visuals piece by piece, you can just connect your data sources and ask questions in plain English like, "What was our average days to ship last quarter?" or "Show me a chart of open ticket age by support agent." Graphed instantly creates the real-time dashboards and reports for you, turning hours of report building into a 30-second task.

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.