What does it mean to pivot variables in tableau and how do you do it? I am new to Tableau and do not have much expertise on data clearning in Tableau.
1 Answers
Assuming by “variable” you mean column, you can go to the data source configuration pane, select multiple columns in the grid, then right-click and choose Pivot. This will transpose (aka restructure) all your selected columns into two new columns. Say you have selected three columns: Col1, Col2, and Col3, and each column contains five values, Pivot generates one column called Pivot Field Names, which contains the column names of the previously selected columns with each name repeated five times and another column called Pivot Field Values containing fifteen rows of values corresponding to the columns from which they came.
Example
Before Pivot:
Col1 | Col2 | Col3 |
---|---|---|
Val1 | Val1 | Val1 |
Val2 | Val2 | Val2 |
Val3 | Val3 | Val3 |
Val4 | Val4 | Val4 |
Val5 | Val5 | Val5 |
After Pivot:
Pivot Field Names | Pivot Field Values |
---|---|
Col1 | Val1 |
Col1 | Val2 |
Col1 | Val3 |
Col1 | Val4 |
Col1 | Val5 |
Col2 | Val1 |
Col2 | Val2 |
Col2 | Val3 |
Col2 | Val4 |
Col2 | Val5 |
Col3 | Val1 |
Col3 | Val2 |
Col3 | Val3 |
Col3 | Val4 |
Col3 | Val5 |
A good use case for pivot might be if you need to consolidate several columns containing data for related items into one category so you can more easily sum all the values. For example, you could create a Cell Phones column and a Cell Phone Sales column by pivoting several individual columns containing sales numbers for individual cell phones. This would allow you to more quickly get a sum of sales for all phones.
There is a great example on the Tableau Help site: https://help.tableau.com/current/pro/desktop/en-us/pivot.htm

- 141
- 4