How to Pivot in Tableau
If you’ve ever tried to build a chart in Tableau with a spreadsheet where every month or category has its own column, you’ve likely felt the frustration. You drag the fields onto your canvas, and instead of a clean, simple line chart, you get a stacked list of measures that’s impossible to work with. This is a classic data structure problem, and Tableau has a surprisingly simple feature to fix it: Pivoting.
This article will guide you through exactly how and why to use Tableau's pivot function. We’ll cover the difference between "wide" and "tall" data, provide a step-by-step walkthrough, and look at a practical example to make it all click.
Understanding "Why" Before "How": Wide vs. Tall Data
Before jumping into the steps, it’s helpful to understand the type of problem that pivoting solves. Most data visualization tools, including Tableau, work best with data that is structured in a "tall" (or normalized) format rather than a "wide" one.
What is Wide Data?
Wide data is a format many of us are used to seeing in spreadsheets. It’s organized to be easily readable for humans. In this format, each observation has its own row, but Measures or Values are split across multiple columns.
For example, a marketing agency might track website sessions by source for each month like this:
See how each month is its own distinct column? This is wide data. If you wanted to create a simple line chart in Tableau showing the trend of sessions over time for Company A, it would be clumsy. You'd have to handle four separate measures (Jan Sessions, Feb Sessions, etc.).
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.
What Is Tall Data?
Tall data organizes the same information differently. Instead of creating new columns for each new time period or category, it adds new rows. There are dedicated columns for the dimensions (the things you are measuring, like "Month") and the measures (the numbers themselves, like "Sessions").
Here’s how the same data above would look in a tall format:
This structure is far more flexible for analysis. In Tableau, you now have a single "Month" dimension you can put on the Columns shelf and a single "Sessions" measure you can put on the Rows shelf to instantly create that trend line. You can filter by month, color by client, and perform calculations with ease. Pivoting is the tool that transforms your wide data into this beautiful, analysis-friendly tall format.
How to Pivot Your Data in Tableau
The good news is that pivoting data from file-based sources like Excel or CSVs is incredibly straightforward in Tableau. You’ll do this on the Data Source page before you even get to your worksheet.
Here’s the breakdown:
Step 1: Connect to Your Data Source
First, open Tableau and connect to your data. This can be a Microsoft Excel file, a text file (like a CSV), or a PDF file. For this example, let's assume you're connecting to an Excel sheet containing the "wide" monthly sales data we showed earlier.
Step 2: Go to the Data Source Page
After you connect to your data and drag your sheet into the canvas, Tableau will display a preview of your data in a grid. This is the Data Source page. You should see your wide column headers like "Jan Sessions," "Feb Sessions," and so on.
Step 3: Select the Columns to Pivot
This is the most important step. You need to tell Tableau which columns you want to unpivot from columns into rows. In our example, these are the monthly columns ("Jan Sessions," "Feb Sessions," "Mar Sessions," "Apr Sessions").
To select multiple columns:
- Click on the first column header you want to pivot (e.g., Jan Sessions).
- Hold down the Shift key and click the last column header (e.g., Apr Sessions) to select all columns in between.
- Alternatively, hold down the Ctrl key (or Cmd on a Mac) and click each column header individually. This is useful if the columns you want to pivot aren't next to each other.
Important Tip: Do not select the columns you want to keep as they are, like "Client." Only select the fields that represent the measures you want to combine.
Step 4: Perform the Pivot
With your columns selected, simply right-click on any of the selected column headers. From the dropdown menu that appears, select Pivot.
Voila! Tableau instantly restructures your data. You’ll see the preview grid update. Your selected columns disappear and are replaced by two new columns.
Step 5: Rename Your New Columns
Tableau creates two new columns with default names:
- Pivot Field Names: This column contains the headers of the columns you pivoted (e.g., "Jan Sessions," "Feb Sessions").
- Pivot Field Values: This column contains the corresponding values from those original columns (e.g., 1200, 1450).
These default names aren't very descriptive. It's a best practice to rename them to something meaningful. To rename a column, double-click on its header, type the new name, and press Enter.
For our example, you could rename:
- "Pivot Field Names" to "Month"
- "Pivot Field Values" to "Sessions"
Now your data is clean, tidy, and ready for analysis! You can go to a worksheet and start building visualizations with your new "Month" dimension and "Sessions" measure.
A Practical Example: Pivoting E-commerce Product Sales
Let's walk through another common scenario. Imagine you have a spreadsheet from your e-commerce platform that shows sales per product, with each region in its own column.
Your wide data looks like this:
It's impossible to create a bar chart that compares regional sales for just the "Premium Coffee Mug" without some complex workarounds.
Here’s how you fix it with a pivot:
- On the Data Source page, select the Sales_US, Sales_CA, and Sales_UK columns.
- Right-click on one of the selected headers and choose Pivot.
- Rename "Pivot Field Names" to "Region".
- Rename "Pivot Field Values" to "Sales".
Your new tall data now looks like this:
Now it's trivial to build that bar chart. Just filter by "Product Name" for "Premium Coffee Mug," put your new "Region" field on the Columns shelf, and your "Sales" field on the Rows shelf. The insight is immediate.
Common Issues & Quick Fixes When Pivoting
While the process is simple, you might run into a few common hurdles. Here’s what to watch out for.
Picking the Wrong Columns
Problem: You accidentally pivoted unique identifier columns (like Product SKU or Client ID) along with your measures.
Solution: On the Data Source page, you can undo the pivot. Look in the "Transform" section of the left-hand pane which lists the cleaning steps you've applied. You can remove the Pivot step and start over, making sure to only select the measure columns you intend to combine.
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.
Mixed Data Types
Problem: Tableau alerts you that you can't create a pivot because the columns have mixed data types (e.g., some sales columns are formatted as numbers and others as text).
Solution: The best place to fix this is in the original source file. Ensure all columns you want to pivot are the same data type. If that's not possible, you can try changing the data type for each column directly in Tableau's Data Source grid before you perform the pivot.
Performance with Huge Datasets
Problem: You are working with a massive dataset with hundreds of "wide" columns and millions of rows, and the pivot operation is slow or causes Tableau to lag.
Solution: For extremely large datasets, performing the pivot directly in Tableau might not be the most efficient method. It's often better to do this transformation upstream using a dedicated data preparation tool like Tableau Prep or with a database query (using UNPIVOT in SQL) before the data ever reaches Tableau Desktop. This pre-processes the data into the optimal format for performance.
Final Thoughts
Pivoting is a fundamental data preparation skill that turns messy, human-readable spreadsheets into a structured format that Tableau loves. By transforming your wide data into a tall format, you unlock far more powerful and flexible visualization capabilities, allowing you to move from data wrangling to impactful analysis much faster.
Mastering techniques like this in Tableau is critical for data analysis, but we often find this kind of manual data prep is the most time-consuming part of any reporting task. We built Graphed to let you skip these steps. Instead of reshaping data, you can connect your sources and just ask in plain English, "Show me a bar chart of my sales by region," and get a live, interactive visualization in seconds, no pivoting required.
Related Articles
How to Create Facebook Ads API for Claude Code
Create a Meta Marketing API access token that never expires, using a system user, so Claude Code can pull Facebook ad reports and manage campaigns.
ClickHouse vs Postgres: When to Switch to Columnar
Comparing ClickHouse vs PostgreSQL means matching storage architecture to workload. Row storage wins for transactions. Columnar wins for scan-heavy analytics.
Google Ads for Orthodontists: Get More Booked Consults
Most orthodontic Google Ads campaigns waste money on low-intent searches. The problem is structure, not the platform.