How to perform multiple pivots in Tableau Prep Builder
Editor's note: Tableau Prep helps everyone quickly and confidently combine, shape and clean their data for analysis. This blog post was updated in April 2019 to reflect current features in Tableau Prep Builder.
People-friendly data is often captured and recorded in a wide format with many columns. Machine-readable data is better in a tall format, with fewer columns and more rows.
Tableau prefers data to be formatted in a machine-readable format. To reshape your data for easier analysis in Tableau, you can perform a pivot. In Tableau, pivoting means transposing data from a cross-tab format into a columnar format – from wide, short tables into thin, tall tables. Tableau Prep Builder makes pivoting visual, allowing you to see how your data changes with every step. In this post, we’ll show how to pivot in Tableau Prep Builder to shape your data for analysis.
How does pivoting work in Tableau Prep Builder?
When we analyse data in Tableau, we need it to be tidy. Each column should have a single unique meaning. So what do you do when your field meanings aren’t unique? When multiple columns means the same thing, you can use pivot.
For example, in this data set, we have data for pharmaceutical sales, taxes and totals by month and year. By pivoting the data, you can create rows for each month and year and individual columns for sales, taxes and totals so that Tableau can more easily interpret this data for analysis.
Learn more about pivoting in Tableau Prep Builder.
How to pivot on multiple fields
What if you want to pivot on multiple fields? Tableau Prep Builder make this easy with the following steps:
- Connect to your data source.
- Drag the table that you want to pivot to the Flow pane.
- Click the plus icon and select Add pivot from the context menu.
- Select one or more fields from the left pane and drag them to the Pivot1 values column in the Pivoted fields pane.
- To add more columns to pivot on, click the plus icon in the Pivoted fields pane in Tableau Prep Builder, then repeat the previous step to select more fields to pivot. Results appear immediately in both the Pivot results pane and the data grid.
Watch “pivot on multiple field” in action.