How to Calculate YTD Sales in Power BI

Cody Schneider••6 min read

Calculating Year-to-Date (YTD) sales is one of the most common and vital metrics for tracking business performance. It instantly tells you how you're performing from the beginning of the year up to the current day. This guide will walk you through a few straightforward methods to calculate YTD sales in Power BI using DAX, step-by-step.

GraphedGraphed

Build AI Agents for Marketing

Build virtual employees that run your go to market. Connect your data sources, deploy autonomous agents, and grow your company.

Watch Graphed demo video

Before You Begin: The Importance of a Date Table

Before writing any time-based calculations in Power BI, it's essential to have a proper Date Table. Time intelligence functions in DAX (the formula language of Power BI) rely on a complete, unbroken series of dates to work correctly. Your sales data might have gaps - no sales on a Sunday or a holiday - but your date table must include every single day.

If you don't have a date table, you can create one easily. In Power BI, go to the Data view, select the Modeling tab, and click New Table. Paste the following DAX code, adjusting the start and end dates to cover your data's full range:

Date = ADDCOLUMNS( CALENDAR(DATE(2020, 1, 1), DATE(2025, 12, 31)), "Year", YEAR([Date]), "Quarter", "Q" & FORMAT([Date], "Q"), "MonthNumber", MONTH([Date]), "MonthName", FORMAT([Date], "mmmm"), "WeekNumber", WEEKNUM([Date]), "DayName", FORMAT([Date], "dddd") )

After creating the table, go to the Model view and connect your 'Date' table to your sales table by dragging the date column from the 'Date' table onto the date column in your sales table. A properly set up date table is the key to accurate reporting. Once your date model is established, your sales transactions are tied to the calendar, simplifying the creation of advanced reporting metrics.

Free PDF · the crash course

AI Agents for Marketing Crash Course

Learn how to deploy AI marketing agents across your go-to-market — the best tools, prompts, and workflows to turn your data into autonomous execution without writing code.

Method 1: The Quickest Way Using TOTALYTD

The simplest way to calculate Year-to-Date sales is with Power BI’s built-in TOTALYTD function. This function is specifically designed for these types of calculations and is very easy to use.

Step-by-Step Instructions

  1. Make sure you have a basic sales measure. If you don't, create one by right-clicking your sales table and selecting New Measure. A simple measure looks like this:
  2. Now, create the YTD measure. Right-click your sales table again and select New Measure.
  3. Enter the following DAX formula:

Breaking Down the Formula

Let's look at what this simple formula is doing:

  • TOTALYTD(): This is the DAX time intelligence function that evaluates an expression over the year-to-date period in the current context.
  • [Total Sales]: This is the first argument or expression. It’s the measure you want to calculate. Here, we're using our simple Total Sales measure.
  • 'Date'[Date]: This is the second argument, representing the dates. It's a reference to the primary date column in your official Date table.

That's all it takes. Now you can use this YTD Sales measure in visuals like charts, tables, or cards. If you drop it into a line chart with 'MonthName' on the axis, you will see a cumulative line sloping upwards through the year as each month's sales are added to the previous total.

Method 2: The Manual Approach with CALCULATE

While TOTALYTD is fantastic for its simplicity, sometimes you need more control, or you want to understand the underlying logic. You can build the same YTD calculation manually using CALCULATE combined with FILTER and some date logic. This approach is more verbose but can be more flexible for complicated scenarios.

GraphedGraphed

Build AI Agents for Marketing

Build virtual employees that run your go to market. Connect your data sources, deploy autonomous agents, and grow your company.

Watch Graphed demo video

Step-by-Step Instructions

  1. Again, start with your base [Total Sales] measure. Let's make a new DAX measure.
  2. Enter the following DAX formula for your manual YTD calculation:

Breaking Down the Formula

This formula might look complex, but it's quite logical when you break it into pieces:

  • CALCULATE([Total Sales], ...): CALCULATE is the most important function in DAX. It modifies the evaluation context of a measure.
  • FILTER(ALL('Date'), ...): The FILTER function returns a table that has been filtered.
  • 'Date'[Year] = MAX('Date'[Year]): This ensures we're only including dates from the current year.
  • && 'Date'[Date] <= MAX('Date'[Date]): This restricts the calculation to include dates only up to and including the current date.

This manual method gives you the exact same result as TOTALYTD but shows you the engine under the hood. It’s a great way to deepen your understanding of how DAX works and serves as an easily modifiable snippet for more challenging calculation variations.

Advanced Scenarios: Fiscal Years and Comparisons

Most businesses have more complex calendars. Power BI and DAX can handle these advanced reporting scenarios with simple modifications to the formulas we’ve discussed.

Handling Fiscal Year-to-Date

Not all companies follow a standard calendar year. For example, a company might start its fiscal year on July 1st. TOTALYTD can handle this by including an optional year-end date parameter.

If your fiscal year ends on June 30th, you simply add "6-30" to the end of the formula:

YTD Fiscal Sales = TOTALYTD([Total Sales], 'Date'[Date], "6-30")

This tells Power BI to use a fiscal year rather than a calendar year to sum up the YTD revenue.

Free PDF · the crash course

AI Agents for Marketing Crash Course

Learn how to deploy AI marketing agents across your go-to-market — the best tools, prompts, and workflows to turn your data into autonomous execution without writing code.

Comparing YTD with Previous Year-to-Date (PYTD)

A very common follow-up question to "What are our YTD sales?" is "And how does that compare to last year?" Calculating Previous Year-to-Date is also easy. You can wrap your YTD calculation inside another CALCULATE function that uses the logic from SAMEPERIODLASTYEAR.

Create a new measure with this formula:

PYTD Sales = CALCULATE([YTD Sales], SAMEPERIODLASTYEAR('Date'[Date]))

This formula compares the YTD sales figures for the current year's period-to-date with the same period last year, allowing for a fair year-over-year comparison.

Final Thoughts

Calculating YTD sales in Power BI is a matter of writing straightforward DAX. Whether you use the simple TOTALYTD function or build a manual calculation for more flexibility, the key lies in having a well-structured date table as your foundation. Mastering this simple formula unlocks powerful, time-based insights that can help guide your business strategy.

At Graphed, we've been working to simplify this process for you. You don't even need to write complex DAX formulas. You can ask in plain English, such as: "Show my total YTD sales compared to last year's by product,” and we instantly connect to your live sales data to create the real-time dashboard answering your question - so there's no need to worry about coding DAX formulas.

Spend less time on report building and more time using this newly-accessible information from your sales reporting to drive your business forward.

Related Articles