How to Perform Retention Analysis in Tableau
Tracking how many customers keep coming back is one of the most powerful ways to gauge the health of your business. While acquiring new customers is exciting, retaining existing ones is often more profitable and a true sign of a great product or service. This article will walk you through exactly how to build a cohort retention analysis chart in Tableau to visualize your customer loyalty over time.
What is Retention Analysis?
Retention analysis measures how many users return to your product or service over a specific period. Instead of looking at a single, overall retention rate, we typically use cohort analysis. A cohort is a group of users who share a common characteristic. For retention analysis, the most common characteristic is when they started using your product - for example, all the customers who made their first purchase in January.
By grouping customers into cohorts, you can see how the behavior of newer customers compares to older ones. This helps you answer important questions like:
- Are our customer retention efforts improving over time?
- Did a recent product update or marketing campaign positively (or negatively) impact customer loyalty?
- How long, on average, do customers stay active after their first purchase?
Visualizing this in Tableau transforms rows of data into a clear, actionable heatmap that tells a compelling story about your customer lifecycle.
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.
Preparing Your Data for Tableau
Before you even open Tableau, the most important step is getting your data ready. A sloppy dataset will lead to a confusing analysis. For a standard retention analysis, you need a dataset listing individual transactions or events. Your data should ideally contain at least two key fields:
- Customer ID: A unique identifier for each customer. This could be an email address, user ID, or a custom number.
- Order Date: The exact date of each transaction or key event (like a sign-up or app session).
Your data might look something like this, pulled from a platform like Shopify, Salesforce, or your own database:
The goal is to use this data to calculate when each customer first appeared (their cohort) and then track their subsequent activity.
Step-by-Step: Building a Retention Chart in Tableau
Once your data is cleaned and ready, it’s time to build the chart. We will create two key calculated fields to define the cohorts and track their activity over time, then assemble them into a powerful visualization.
Step 1: Connect to Your Data
Open Tableau and connect to your data source (e.g., a CSV, Excel file, or Google Sheet). Once connected, drag your data sheet into the workspace to see a preview. Tableau should automatically recognize your fields like Customer ID and Order Date.
Step 2: Create the Customer Cohort Field
First, we need to assign each customer to a cohort based on their first purchase date. We can do this using a Level of Detail (LOD) expression. LOD expressions allow you to compute values at a different level of detail than what's in the view.
- Go to the top menu and select Analysis > Create Calculated Field.
- Name this field Cohort Month.
- Enter the following formula:
{ FIXED [Customer ID] : MIN([Order Date]) }
This formula tells Tableau: "For each unique Customer ID, find the earliest (minimum) Order Date." This date will be the same for all transactions associated with that customer, effectively grouping them into their starting cohort. Click "OK".
After creating the field, right-click on it in the Data pane, go to Default Properties > Date Format, and choose a format like "Month Year" (e.g., "January 2023") for readability.
Step 3: Calculate Months Since First Purchase
Next, we need to figure out the timeline for our chart. We want to see customer activity in Month 0 (their first purchase month), Month 1 (the month after), Month 2, and so on. To do this, we calculate the difference in months between each order date and the customer's cohort date.
- Create another calculated field and name it Months Since First Purchase.
- Enter this formula:
DATEDIFF('month', [Cohort Month], [Order Date])
The DATEDIFF() function calculates the difference between two dates. Here, it’s counting the number of month transitions between the Cohort Month and the Order Date for each transaction. This will give us a numerical value (0, 1, 2, ...).
Step 4: Build the View
Now we have all the pieces we need to assemble the retention chart.
- Drag the Cohort Month field to the Rows shelf. Right-click it and make sure it's set to "Discrete" (it should be a blue pill). You’ll see a list of every cohort in your data.
- Drag the Months Since First Purchase field to the Columns shelf. Right-click this field, and select "Convert to Discrete". This will create columns labeled 0, 1, 2, 3, etc., representing the timeline.
- Now we need to count how many customers from each cohort were active in each subsequent month. Drag the Customer ID field onto the Text mark on the Marks Card.
- By default, Tableau might just list the IDs. We need to aggregate them. Right-click on the Customer ID pill on the Marks card, go to Measure, and select Count (Distinct). This is very important!
COUNTD()ensures that even if a customer makes multiple purchases in a month, they are only counted once for that period.
You should now have a grid of numbers showing the raw count of active customers for each cohort over time.
Step 5: Visualize Retention as a Percentage
Absolute numbers are great, but percentages tell a clearer story. We want to see what percentage of the initial cohort (Month 0) came back each month.
- Right-click the
COUNTD(Customer ID)pill on the Marks card and select Quick Table Calculation > Percent of Total. - Your numbers will change to percentages, but they might not be calculating correctly yet. By default, Tableau may be calculating the percent of the grand total across the entire table.
- Right-click the same pill again, go to Compute Using, and select Table (Across). This changes the calculation to be based on the total for each row. The first column (Month 0) for each cohort will now show 100%, and subsequent columns will show the percentage of that initial group that returned.
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.
Step 6: Turn It Into a Heatmap
The final touch is to add color to make spotting trends feel effortless. A heatmap is the standard visualization for cohort analysis.
- Hold down Ctrl (or Cmd on Mac) and drag the
COUNTD(Customer ID)pill (the one with the table calculation) from the Text mark to the Color mark on the Marks card. - On the Marks card, change the dropdown menu from "Automatic" to Square. This will fill each cell with a color-coded box.
Now you have a fully functional cohort retention heatmap! You can customize the colors by clicking the Color mark and choosing a different color palette (a sequential one, like blue or green, often works best). Darker colors represent higher retention, making it easy to see where your customers are sticking around the most.
Reading and Interpreting Your Retention Chart
You’ve built the chart, but what does it all mean? Here’s how to read it:
- Read Horizontally (Across a Row): This follows a single cohort over time. In a healthy business, you will see a gradual decline from left to right, but hopefully, it flattens out. A steep drop-off at a certain point (e.g., from Month 1 to Month 2) might signal an issue with onboarding or the early customer experience.
- Read Vertically (Down a Column): This compares different cohorts at the same point in their lifecycle. For example, looking at the "Month 3" column shows you the retention rate for all cohorts in their third month. If you see that numbers are increasing for newer cohorts at the bottom, your retention strategies are likely working!
- Look for Patterns: Are certain cohorts significantly better than others? Maybe a marketing campaign you ran in May brought in a much more loyal customer base. Does your retention tank after 6 months for everyone? Perhaps your product isn't fitting into long-term workflows. These are the insights that drive real business decisions.
Final Thoughts
Building a cohort retention chart in Tableau provides a clear, detailed window into customer loyalty and business health. By following these steps, you can transform raw sales or event data into an actionable dashboard that isolates where your customer experience shines and where it needs improvement.
While Tableau is a fantastic tool, it still requires multiple steps, calculated fields, and specific settings to get right. If you want insight like this without the manual setup, you might appreciate the approach we're building at Graphed. We connect directly to your data sources like Shopify or Google Analytics and allow you to build complex dashboards simply by asking for what you want in plain English. Instead of creating LOD calculations and configuring table calcs, you can just ask, "Show me a monthly customer retention heatmap," and get a live, automated dashboard in seconds.
Related Articles
Facebook Ads For Beauty Salons: The Complete 2026 Strategy Guide
Learn the proven Facebook ad strategies that successful beauty salons are using to attract new clients, increase repeat bookings, and grow their revenue in 2026.
Facebook Ads for Wedding Planners: The Complete 2026 Strategy Guide
Learn how to use Facebook ads to book more wedding planning clients in 2026. Complete guide covering targeting, budgets, retargeting, and conversion strategies.
Facebook Ads for Bands: The Complete 2026 Strategy Guide
Learn how to use Facebook Ads to promote your band in 2026. This comprehensive guide covers audience targeting, budget strategies, creative tips, and measurement techniques specifically for musicians.