How to Calculate MTD in Tableau
Calculating month-to-date (MTD) performance is a fundamental task in any dashboard, but getting it right in Tableau can feel a bit tricky at first. This straightforward guide will walk you through several reliable methods for calculating MTD, from a simple boolean filter to more flexible calculations that allow for dynamic comparisons. You'll learn how to isolate current MTD data, visualize your progress, and set up your workbook for smarter, real-time insights.
Why MTD is a Big Deal for Reporting
Before jumping into the formulas, it's worth remembering why MTD is such a staple in business intelligence. Tracking MTD metrics allows you to:
- Monitor Progress in Real-Time: Instead of waiting until the month ends, MTD figures tell you how you're pacing towards your monthly goals right now. Are sales on track? Is website traffic picking up as expected?
- Identify Trends Early: Did a new marketing campaign cause a spike in leads this week? Is a certain product category underperforming mid-month? MTD analysis helps you spot these patterns early enough to take action.
- Make Timely Adjustments: If your MTD numbers are flagging, you have time to diagnose the problem and adjust your strategy. You might decide to boost ad spend, run a flash sale, or reach out to a specific sales territory. Without MTD, you're flying blind until it's too late.
The Core Ingredients: Tableau's Calculated Fields and Date Functions
Tableau's power lies in its ability to create custom calculations. For MTD, we'll primarily use "Calculated Fields" along with a handful of essential date functions:
TODAY(): This super useful function simply returns the current date. It's the anchor that makes your MTD calculation dynamic, automatically updating every day.DATETRUNC('date_part', [date_field]): This function "truncates" a date to the first day of a specified period. For example,DATETRUNC('month', #2023-11-21#)returns2023-11-01. It's perfect for grouping all dates within the same month.
We'll use these building blocks in a few different ways to get our MTD numbers.
Method 1: The Simple Boolean Filter
This is often the cleanest and most efficient way to analyze MTD performance. We'll create a single calculated field that returns either "True" or "False" depending on whether a record falls within the MTD period. Then, we just filter our view to only show the "True" values.
This method isolates your entire worksheet to the MTD period, which is great for building MTD-specific dashboards.
Step 1: Create the Calculated Field
First, open a workbook using a dataset with a date field (we'll use the sample Superstore dataset and its [Order Date] field).
- Right-click anywhere in the Data pane on the left and select Create Calculated Field.
- Name the field something clear, like Is MTD?.
- Enter the following formula into the editor:
[Order Date] <= TODAY()
AND
DATETRUNC('month', [Order Date]) = DATETRUNC('month', TODAY())
Step 2: Understand the Formula
Let's break that down piece by piece:
[Order Date] <= TODAY(): This part of the logic ensures you don't include data from the future. It checks if the transaction date is on or before today.DATETRUNC('month', [Order Date]) = DATETRUNC('month', TODAY()): This is the core of the MTD logic. It checks if the first day of the month for the[Order Date]is the same as the first day of the current month. If today is November 21, 2023, this will return TRUE for any order date in November 2023.
The AND operator requires both conditions to be met for the result to be True.
Step 3: Apply the Filter
Now, drag your newly created Is MTD? field from the Data pane onto the Filters shelf. A dialog box will appear. Select True and click OK.
That's it! Any visualization you build on this sheet is now filtered to show only data from the first of the current month up to today. For example, if you drag Sales to the Text card, it will show you the total sales for the MTD period.
Method 2: Using an IF Statement in a Calculation
The boolean filter is great, but what if you want to compare MTD sales against total sales for the month or year on the same chart? A filter limits the entire view, which won't work in that case.
The alternative is to embed the MTD logic directly into a measure. This gives you a new, standalone measure like "MTD Sales" that you can use alongside other measures.
Step 1: Create the MTD Measure
- Create a new calculated field and name it MTD Sales.
- Enter this formula:
IF [Order Date] <= TODAY() AND DATETRUNC('month', [Order Date]) = DATETRUNC('month', TODAY())
THEN [Sales]
ELSE 0
END
Step 2: Understand the Formula
This formula uses the same logical test as our boolean filter, but it works a little differently:
- It checks each row of data. If the
[Order Date]falls within the MTD period, it returns the value from the[Sales]column for that row. - If the date is outside the MTD period, it returns a
0orNULL. Using0is often easier as it prevents potential issues with aggregations.
Now, when you use this field in a view — for instance, SUM([MTD Sales]) — Tableau will sum up all the sales values for MTD days and add a bunch of zeros for all other days, giving you the correct total.
Step 3: Use the New Measure
You can now build charts that use this measure directly. Try this:
- Drag Category to the Rows shelf.
- Drag your new [MTD Sales] measure to the Columns shelf.
You'll get a bar chart showing a breakdown of MTD sales by product category, without needing any filters on the Filters shelf.
Advanced Method: Allowing Users to Select a Date Dynamically with Parameters
Hardcoding TODAY() is perfect for dashboards that always need to show current performance. But what if you want to analyze the MTD period for a past date? For example, "What were our MTD sales on January 15th, 2022?"
For this, we'll use a Parameter, which lets the user pick a date from a calendar control.
Step 1: Create a Date Parameter
- Right-click in the Data pane and select Create Parameter.
- Configure the parameter:
- Click OK. Your new parameter will appear at the bottom left of the Data pane. Right-click it and select Show Parameter. A date-picker control will now appear on your canvas.
Step 2: Update Your MTD Calculation
Now we just need to edit our existing MTD calculations to use the parameter instead of the TODAY() function.
For the boolean filter (Method 1):
Create or edit a calculated field called Is MTD (Parameter)?
[Order Date] <= [Select a Date]
AND
DATETRUNC('month', [Order Date]) = DATETRUNC('month', [Select a Date])
For the embedded measure (Method 2):
Create or edit a calculated field called MTD Sales (Parameter):
IF [Order Date] <= [Select a Date] AND DATETRUNC('month', [Order Date]) = DATETRUNC('month', [Select a Date]))
THEN [Sales]
ELSE 0
END
Now, when a user picks a date from the parameter control — say, July 22, 2023 — your calculations will automatically show results for the period of July 1 to July 22, 2023. This is incredibly powerful for historical analysis and exploration.
Quick Tips for Visualizing MTD Data
Calculating the metric is half the battle, presenting it effectively is just as important.
- KPI Cards: For a headline MTD number, use a new sheet. Drag your MTD measure (e.g.,
[MTD Sales]) to the Text mark. Enlarge the font and add it to your dashboard. This is your "big number" that gives an at-a-glance view. - Bar Charts for Comparison: As shown earlier, bar charts are perfect for comparing MTD performance across different categories, regions, or products.
- Daily Trend Lines: To see the rhythm of the month, create a line chart. Use your regular
SUM([Sales])measure on the Rows shelf. Place a continuous (green) version of your date field set to DAY on the Columns shelf. Finally, apply your Is MTD? boolean as a filter. This will show a daily trend line for the month-to-date period.
Final Thoughts
Today you've seen how to build robust, dynamic month-to-date calculations in Tableau. Whether you prefer the simple boolean filter for MTD-focused dashboards or the more flexible IF statement for comparative analysis, the combination of TODAY() and DATETRUNC() is your MTD toolkit. Using parameters takes this a step further, allowing for truly interactive historical analysis.
As BI professionals, we spend a lot of time creating those robust calculations inside tools like Tableau. We know first-hand how much work it can take to set up all the necessary data sources, calculations, and visualizations just to answer a basic question. We built Graphed to remove this friction. With it, you simply connect your data and ask questions in plain English - like "what were my MTD sales on Shopify broken down by campaign" - and get a finished chart or dashboard in seconds without touching a calculation editor once.
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.
DashThis vs AgencyAnalytics: The Ultimate Comparison Guide for Marketing Agencies
When it comes to choosing the right marketing reporting platform, agencies often find themselves torn between two industry leaders: DashThis and AgencyAnalytics. Both platforms promise to streamline reporting, save time, and impress clients with stunning visualizations. But which one truly delivers on these promises?