EDUCBA Logo

EDUCBA

MENUMENU
  • Explore
    • EDUCBA Pro
    • PRO Bundles
    • Featured Skills
    • New & Trending
    • Fresh Entries
    • Finance
    • Data Science
    • Programming and Dev
    • Excel
    • Marketing
    • HR
    • PDP
    • VFX and Design
    • Project Management
    • Exam Prep
    • All Courses
  • Blog
  • Enterprise
  • Free Courses
  • Log in
  • Sign Up
Home Data Science Data Science Tutorials Tableau Tutorial Pivot in Tableau
 

Pivot in Tableau

Priya Pedamkar
Article byPriya Pedamkar

Updated March 22, 2023

Pivot in Tableau

 

 

Introduction to Pivot in Tableau

Pivot in general means a point that supports turning towards any direction coupled with balancing. With respect to data-based operations, the concept came from MS Excel, where Pivot tables help deal with data, the way the user wants. Tableau too offers a mechanism to pivot data, supporting aggregation and data arrangement functionalities based on the user requirements. The new fields that are created after pivoting can be successfully leveraged to create insightful visualizations that are otherwise not possible to generate. Moreover, Tableau doesn’t restrict the user here as the pivoted data can also be un-pivoted to its original state.

Watch our Demo Courses and Videos

Valuation, Hadoop, Excel, Mobile Apps, Web Development & many more.

Steps to Create Pivot in Tableau

Now, we shall see the step-by-step process to pivot data in Tableau. For this demonstration, we are considering sales data for twenty major cities in India. The sales figures are present year wise. Years from 2010 to 2018 are present as columns and against them, the sales figures are present for respective cities. We’ll import this data into Tableau, and work pivot operation over it for analysis.

1. To load the data source, click on “New Data Source” in the Data menu. Alternatively, click on “Connect to Data”.

Pivot in Tableau 1

2. Select the requisite data source type. In this case, the data source is present as a Microsoft Excel file, so click on Microsoft Excel, and select the file.

Pivot in Tableau 2

3. The data gets loaded into Tableau as below.

Pivot in Tableau 3

4. The following screenshot gives a closer look at the dataset. As can be seen in the following screenshot, each year is present as a separate column. And a row indicates sales for a city across different years.

Pivot in Tableau 4

5. With the existing arrangement, it is not possible to view aggregated sales for a city as sales figures are present for different years separately. Using the “Pivot” option helps us overcome this. Select all the columns that we intend to pivot, like, in this case, we shall select all the year columns. Right-click on the selected columns and click on the Pivot option as illustrated in the below screenshot.

Pivot in Tableau 5

6. As soon as we click on the “Pivot” option, the data gets pivoted as shown below. The default names for new fields created as a result of pivoting are “Pivot Field Names” and “Pivot Field Values” for dimension and measure respectively. However, we shall rename them with meaningful names.

Pivot in Tableau 6

7. To rename a pivot field, just double click over it and type the requisite name. The name should suit the context and meaningfully convey the crux of the field.

Pivot in Tableau 7

8. We successfully renamed Pivot Field Names and Pivot Field Values as Year and Sales respectively as illustrated below.

Pivot in Tableau 8

9. Moving to the sheet tab, we can see that pivot fields have successfully been brought into which we can now use for analysis. They are highlighted as shown in the below screenshot.

Pivot in Tableau 9

10. Just drag newly created dimension Year into Columns region and measure Sales into Rows region. We get a visualization depicting year wise sales for all the cities as below. Note, the default chart type is a bar chart that can be changed from the Marks card.

Pivot in Tableau 10

11. From the Marks card, change the chart type to Line and we get a line depicting the sales trend over the period under consideration. For better insights and analysis, we will modify this chart slightly. In Marks card, click on Color. In Color, under Markers, select the “All” option. Performing these steps will give us a line chart with markers as can be seen in the below screenshot.

change the chart type to Line

12. The line chart indicates an increasing trend from 2010 to 2018. However, as an analyst, we may want to get deeper into sales figures. To make the sales figures visible around the labels, just drag Sales on Label in Marks card. We get a line chart with Sales figures as shown in the below screenshot.

line chart

The above graph is more insightful and offers an easy and quick way to make year over year comparisons and percentage calculations.

13. In the above analysis, we worked over total sales. Sometimes, it becomes important to analyze the average sales. In our example, to analyze average sales over a period of time, we will have to change the aggregation measure from SUM (Sum) to AVG (Average). Note, we have Sales present in the Columns region as well as the Marks card, so we will have to modify the aggregation measure at both the places. To change the aggregation measure, click on the drop-down menu of the dimension Sales, then in the “Measure” section select “Average”. The following screenshot shows the procedure to change the aggregation measure in the Marks card and the subsequent screenshot shows the procedure for dimension Sales present in the Columns region.

total sales 1

total sales 2

14. The following screenshot shows the average sales trend for twenty major cities across India for the period 2010 to 2018.

average sales trend

In the above part, we saw how pivoting data helps us perform crucial analysis and work with the data using different aggregation measures and data arrangement options. This is a crucial aspect of pivot in Tableau.

15. We can remove the pivot and restore the data to its original state. To remove the pivot, just right click on any pivoted field, and click on the “Remove Pivot” option.

Remove Pivot option

16. The below screenshot shows how clicking over the “Remove Pivot” option restored the data to its original state. This is important because, based on the requirement we can pivot the data, perform analysis and once the purpose is served, restore the data to the original state. This serves two purposes: Performing Analysis and Keeping the data intact.

Remove Pivot

17. Just see what happens if we do not pivot the data and used it as it is for analysis. As we can see in the below screenshot, separate years appear as separate measures and it is not possible to aggregate them so as to get a year-wise sales trend. Remember, we have overcome this using Pivot.

year-wise sales trend

Conclusion

Deriving its name from the mechanical pivot, the pivot functionality in database operations refers to the mechanism to work over and aggregate data as required. The Pivot option in Tableau helps to work with the data to obtain a suitable data arrangement which can be further used for context-based analysis.

Recommended Articles

This is a guide to Pivot in Tableau. Here we discuss the Step-by-Step Procedure to create Pivot in Tableau and also work pivot operation over it for analysis. You may also look at the following article to learn more –

  1. Parameters in Tableau
  2. Tableau Dashboard Design
  3. Tableau Chart Types
  4. Pivot in Tableau
  5. Tableau Context Filter

Primary Sidebar

Footer

Follow us!
  • EDUCBA FacebookEDUCBA TwitterEDUCBA LinkedINEDUCBA Instagram
  • EDUCBA YoutubeEDUCBA CourseraEDUCBA Udemy
APPS
EDUCBA Android AppEDUCBA iOS App
Blog
  • Blog
  • Free Tutorials
  • About us
  • Contact us
  • Log in
Courses
  • Enterprise Solutions
  • Free Courses
  • Explore Programs
  • All Courses
  • All in One Bundles
  • Sign up
Email
  • [email protected]

ISO 10004:2018 & ISO 9001:2015 Certified

© 2025 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

EDUCBA Login

Forgot Password?

🚀 Limited Time Offer! - 🎁 ENROLL NOW