How to Combine Two Date Fields in Tableau

Cody Schneider••7 min read

Working with date fields in Tableau often means dealing with separate start and end dates. Whether analyzing project timelines, marketing campaign durations, or customer subscription periods, you need a way to bring these two points in time together to see the full picture. This tutorial will walk you through several practical methods for combining start and end dates in Tableau to calculate durations and build insightful visualizations like Gantt charts.

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

Why Combine Date Fields in Tableau?

Before jumping into the "how," it's helpful to understand the "why." Your raw data might contain columns like Campaign Launch Date and Campaign End Date, or Subscription Start and Subscription Churn. While useful on their own, the real insights come when you connect them. Combining these fields unlocks several key analytical capabilities:

  • Calculating Duration: The most immediate benefit is measuring the time between two points. How long did a sales cycle take? What is the average customer lifetime? How many days did specific projects run?
  • Visualizing Timelines: By connecting start and end dates, you can build powerful timeline-based views like Gantt charts. This is perfect for tracking project schedules, marketing campaign overlaps, or employee tenure.
  • Analyzing Concurrency: Combining dates helps you answer questions about overlap. For example, how many active campaigns were running in June? Or on a specific date, how many customer subscriptions were active at any given day?
  • Creating a Single Time Axis: For certain charts, you need a single, continuous date axis that reflects activity over a period, not just an event at a single point in time. Combining dates makes this possible.

Let's walk through the most effective methods to achieve these results.

Method 1: Calculate Duration Using DATEDIFF

The most straightforward way to combine two date fields is to calculate the duration between them. Tableau's built-in DATEDIFF function is perfect for this. It returns the difference between two dates, expressed in the time units you specify (days, weeks, months, etc.).

Imagine your data source has a [StartDate] and an [EndDate] field. Here’s how you can calculate the duration in days.

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-by-Step Instructions:

  1. Create a Calculated Field: In your Tableau worksheet, right-click on any field in the Data pane and select Create a Calculated Field.
  2. Name Your Field: Give your new calculation a descriptive name, like "Project Duration (Days)".
  3. Write the DATEDIFF Formula: In the calculation editor, type the following formula:
  4. Click OK: Tableau will create a new measure in your Data pane called "Project Duration (Days)".

You can now use this new measure just like any other number in your dataset. For example, you can drag it onto your sheet to find the average project duration or create a bar chart showing the duration of each individual project.

Tip: Handling Ongoing Projects or Subscriptions

What if the EndDate is null because the project is still active? The DATEDIFF function will return a null value. You can get around this by using the TODAY() function to calculate the duration up to the current date.

Modify your calculated field with an IFNULL or IF ISNULL statement:

DATEDIFF('day', [StartDate], IFNULL([EndDate], TODAY()))

This formula tells Tableau: "If the EndDate field is not null, use it. If it is null, use today's date instead." This makes your duration calculation dynamic for ongoing activities.

Method 2: Visualize a Timeline with a Gantt Chart

Calculating duration is one thing, but visualizing it on a timeline is often more impactful. A Gantt chart is the standard way to show start and end dates visually, which is surprisingly easy to create in Tableau once you have your duration calculation.

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:

Let's use the "Project Duration (Days)" calculation we just created.

  1. Set Up Your Rows and Columns: Drag the dimension that defines each event (e.g., Project Name or Campaign ID) to the Rows shelf. Then, drag your [StartDate] field to the Columns shelf. Right-click the [StartDate] pill on the Columns shelf and make sure you select the continuous Day option (the one with a green calendar icon).
  2. Change the Mark Type: On the Marks card, click the dropdown menu and select Gantt Bar. You should see thin lines appear next to each project, starting on their respective start dates.
  3. Add Duration to Size: Now, drag your Project Duration (Days) calculated field onto the Size property on the Marks card.

Instantly, the thin lines will extend to represent the duration of each project, creating a fully functional Gantt chart. From here, you can sort the projects, add colors based on status or category, and customize tooltips to display key details.

Method 3: Create a Master Calendar with Data Scaffolding

What if you want to answer questions like, "On any given day in Q2, how many projects were active?" Calculating duration with DATEDIFF won't solve this, because it just produces a single number for the entire period. You need a way to make Tableau aware of every single day between the start and end dates.

This is where data scaffolding comes in. The idea is to create a separate file containing a single column with a list of all dates, then join it to your project data. This technique is more advanced but unlocks deeper analysis.

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-by-Step Instructions:

  1. Create a Scaffold File: Open Excel or Google Sheets. In the first column, create a title called "Calendar Date". In the first cell, enter the earliest possible date in your data (e.g., 1/1/2022). Then, drag the fill handle down to populate every day until a date well past your latest end date. Save this file (as an Excel file or CSV).
  2. Connect to Your Data in Tableau: Connect Tableau to your primary data source (with Start and End dates). Then, add a connection to your new calendar scaffold file.
  3. Join the Two Data Sources: Double-click on your primary data source to open the physical data model view. Drag your calendar scaffold sheet onto the canvas. Tableau will try to create a join. You'll need to define custom join conditions.
  4. Configure the Join Logic: Click on the join relationship icon (the Venn diagram) and set up the following join conditions:

This logic tells Tableau to create a row for every single day that a project was active. One single project that ran for 30 days will now have 30 rows in your data source, one for each day it was active.

  1. Analyze Your New Dataset: Now you can create powerful visualizations:

Data scaffolding requires extra setup but gives you granular control over time-based analysis, enabling you to answer complex questions that are otherwise very difficult to solve in Tableau.

Final Thoughts

Combining two date fields in Tableau allows you to transform simple start and end points into powerful insights about duration, timelines, and business performance. Whether you use the simple DATEDIFF function, visualize timelines with Gantt charts, or create a flexible master calendar with data scaffolding, you can unlock a much deeper understanding of your data.

While Tableau gives you the tools, gathering and preparing all that data can still be challenging. Instead of manually wrangling data from different systems just to line up your dates, we created a faster way with Graphed. You can connect sources like Shopify, Salesforce, and Google Analytics in a few clicks. From there, you just ask our AI data analyst in plain English to build the report for you — like "show me the average duration of our sales cycle from close by HubSpot contact source." and get a real-time dashboard without spending hours in a BI tool.

Related Articles