How to Get Previous Month Value in Tableau
Comparing this month's performance to last month's is one of the most fundamental tasks in data analysis. It tells you if you're growing, shrinking, or holding steady. This article will show you exactly how to get the previous month's value in Tableau using two powerful methods, so you can build out those essential month-over-month reports.
Why Context is Everything: The Value of Previous Month Data
Looking at a single number, like "$50,000 in sales this month," is great, but it lacks context. Is that good? Bad? About average? Without a benchmark, it’s just a number floating in space. Comparing it to the previous month's value of $40,000 immediately gives it meaning - you’re up 25%!
Tracking performance against the prior month helps you:
- Spot Trends: Are your sales consistently climbing month after month? Did a change in marketing strategy cause a sudden dip? These trends become visible when you have a comparison point.
- Measure Growth: Month-over-Month (MoM) growth is a core KPI for nearly every business, from marketing teams tracking leads to sales teams tracking revenue.
- Diagnose Issues: If your website traffic dropped significantly from last month, you know you need to investigate. Was it a seasonal dip, a technical problem, or a change in ad performance? The comparison sparks the right questions.
- Evaluate Initiatives: Did you launch a new ad campaign this month? Comparing this month’s results to last month’s pre-campaign baseline shows you its immediate impact.
Getting this comparison right is the first step toward turning raw data into an actionable story about your business performance.
Before You Calculate: Check Your Date Field
Before jumping into formulas, take one second to make sure Tableau recognizes your date field as an actual date. In the data pane on the left, your date dimension should have a little calendar icon next to it. If it has "Abc" or a "#" sign, Tableau sees it as text or a number.
If needed, you can fix this by clicking the icon and changing the data type to Date or Date & Time. Solid calculations are built on a solid foundation, and getting your date field right is step one.
Method 1: The Quick & Visual Approach Using LOOKUP()
The fastest way to get a prior month’s value is with a Table Calculation. Think of table calculations as special formulas that work on the data currently visible in your chart or table. They're perfect for quick, on-the-fly comparisons.
The star of this method is the LOOKUP() function.
Step-by-Step Instructions:
Let's say we want to compare monthly sales. Start by building a simple view.
- Drag your date dimension (we’ll use Order Date) to the Columns shelf. Right-click it and choose the continuous "MONTH(Order Date)" option (the one with the green calendar icon).
- Drag your measure (like Sales) to the Rows shelf. You should now have a basic line chart showing sales over time.
- Now, let's create our calculated field. Click the dropdown arrow at the top of the data pane and select Create Calculated Field.
- Name the field something clear, like "Previous Month Sales".
- In the formula box, type the following:
LOOKUP(SUM([Sales]), -1)What Does This Formula Mean?
It’s simpler than it looks:
SUM([Sales]): This first part tells Tableau what value we're interested in — the sum of sales for each mark (or month) in our view.LOOKUP(..., -1): TheLOOKUPfunction tells Tableau to “look up” that value in a different position in the table. The-1is the key part, it means "go back one step from the current position." In our monthly view, this translates to "get the value from the previous month." If you wanted to look two months back, you’d use-2.
Adding it to the View
Drag your new "Previous Month Sales" calculated field from the data pane directly onto the Rows shelf next to your original SUM(Sales) pill. You will now see two lines: one for the current month's sales and one for the previous month's sales.
You can see that for the first month in your chart, the "Previous Month Sales" value is null. This is perfectly normal - there's no data before that point to look up!
Pros and Cons of the LOOKUP() Method
- Pros: It’s incredibly fast and easy to implement. It’s perfect for visual analysis and building straightforward charts.
- Cons: It relies entirely on the visual layout of your worksheet. If you reorganize your chart or a filter removes a month, the calculation can "break" or show an incorrect value because the relative position of the data has changed.
Method 2: The Robust & Flexible Approach with LOD Expressions
When you need a more reliable and portable value that isn’t dependent on your chart's structure, Level of Detail (LOD) expressions are the solution. An LOD expression calculates a value at a specified level, independent of what’s in your view. This means you can calculate "total sales for last month" and use that single value anywhere — in a chart title, as a KPI, or in another calculation, without worrying about filters (mostly).
This method takes a few more steps, but the payoff is a much more robust calculation.
Step-by-Step Instructions:
We'll create two calculated fields: one to identify the start date of the previous month, and another to get the sales for that specific month.
Step 1: Get the Previous Month's Start Date
First, we need to tell Tableau exactly which date we are looking for. Let’s make it dynamic so it always finds the month prior to the most recent month in your dataset.
- Create a new calculated field and name it "Previous Month Start Date".
- Enter this formula:
DATE(DATETRUNC('month', DATEADD('month', -1, {MAX([Order Date])})))What Does This Formula Mean?
Let's read this from the inside out:
{MAX([Order Date])}: This is a simple LOD that finds the single latest date in your entire dataset.DATEADD('month', -1, ...): This takes that latest date and subtracts one month from it.DATETRUNC('month', ...): This function "truncates" the date to the beginning of its month. So,August 28thbecomesAugust 1st.DATE(...): This just ensures the final output is a clean date format.
The result is a single, static date: the first day of the previous calendar month based on your data.
Step 2: Calculate Previous Month's Sales with an LOD
Now that we have our target date, we can use another calculated field to sum up the sales for only that month.
- Create another new calculated field named "Previous Month Sales (LOD)".
- Enter this formula:
{FIXED : SUM(IF DATETRUNC('month', [Order Date]) = [Previous Month Start Date] THEN [Sales] END)}What Does This Formula Mean?
IF DATETRUNC('month', [Order Date]) = [Previous Month Start Date]: This is a logical test. For every single row in your data, it truncates the order date to the first of its month and checks if it matches the "Previous Month Start Date" we just calculated.... THEN [Sales]: If the dates match, it returns the sales value for that row. If not, it returns null.{FIXED : SUM(...)}: TheFIXEDLOD tells Tableau to sum up all the sales values that passed the IF statement, across the entire dataset. This gives you one single, unchanging number representing the total sales for the previous month.
Now you have a "Previous Month Sales (LOD)" measure that you can drag onto a KPI card, use in a tooltip, or reference in other calculations, and it will always hold the correct value. This makes it incredibly powerful for dashboards.
Pros and Cons of the LOD Method
- Pros: Extremely robust and portable. The value remains correct regardless of your visual layout or most filters. It’s the best practice for building reliable KPIs.
- Cons: It’s more complex to write and can sometimes be slower on tremendously large datasets (though for most use cases, it’s plenty fast).
Putting It All Together: Calculating MoM Growth
Now for the best part! With either method, you can easily calculate Month-over-Month growth.
Create a final calculated field, "MoM Sales Growth %". The formula template is:
(Current Period - Previous Period) / Previous Period
- If using the LOOKUP() method:
(SUM([Sales]) - LOOKUP(SUM([Sales]), -1)) / LOOKUP(SUM([Sales]), -1)- If using the LOD method: (This requires you to create another LOD for current month sales first)
(SUM([Current Month Sales (LOD)]) - SUM([Previous Month Sales (LOD)])) / SUM([Previous Month Sales (LOD)])Once you've created the calculation, drag it into your view. Then, right-click it, go to Default Properties > Number Format..., and choose Percentage to display it correctly.
Final Thoughts
Calculating the previous month's value is a gateway to deeper analysis in Tableau. For quick visuals, the LOOKUP() function is your best friend. For building reliable and reusable metrics for dashboards and KPIs, mastering LOD expressions is the way to go.
Sometimes, though, you just need a key number without writing formulas or setting up charts. We built Graphed for exactly those moments. You can connect your data sources and simply ask in plain English, "Compare our sales this month vs. last month" or "What was our month-over-month revenue growth?". We instantly pull the right data and generate the report you need, turning hours of analysis 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.
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?