02 - Data - Analysis-Pivot Table
02 - Data - Analysis-Pivot Table
1
Disclaimer
This presentation is purely for academic purpose and does not carry
any commercial value.
All non-academic images used in this presentation are property of
respective image holder(s). Images are used only for indicative
purpose and does not carry any other meaning.
2
Please follow this…
3
Analyze Data
Using
Pivot Table
Data Analysis Using Excel
4
Text Book
TEXT BOOK
Hector Guerrero, “Excel Data Analysis - Modeling and Simulation”, Springer-Verlog
Camm, Cochran, Fry, Ohlmann, Anderson, Sweeney, Willians, “Essentials of Business
Analytics”, Cenage Learning
5
TABLE OF CONTENT
1 Why Table and Pivot Table?
8 Example –
6
Data Set Used
Data Set will be shared separately.
CarSell.xlsx
SalesData.xlsx
SalesOrders.xlsx
SurveyWebPageDesign.xlsx
Autosales.xlsx
7
TABLE & PIVOT TABLE
1
8
Why Table?
9
What is PivotTable?
10
Why PivotTable?
PivotTable simply allows to make better sense of data by giving
different options of how to view that data.
You can group data into categories, break down data into years and
months, filter data to include or exclude categories, and even build charts.
11
Why PivotTable – Describe & Discover
PivotTable simply allows to make better sense of data by giving
different options of how to view that data.
You can group data into categories, break down data into years and
months, filter data to include or exclude categories, and even build charts.
12
Why PivotTable – Interactive & Dynamic
PivotTables has interactive features hence with very little effort (and no
formulas) you can look at the same data from many different perspectives.
13
ANSWER BUSINESS QUESTIONS WITH PIVOT TABLE
There are many business questions that require the collection and analysis
of quantitative and qualitative data.
For example,
How does a visitor’s opinion of a commercial website relate to her
purchases at the website?
Does a positive opinion of the website, relative to a bad opinion, lead to
higher sales? This type of information is often gathered in the form of an
opinion and measured as a categorical response.
14
SKILLS OF PIVOT TABLE
2
15
Skills
Students are expected to develop below skills. Use Microsoft
Official site -
Create a PivotTable to analyse worksheet data
Create a PivotChart
https://support.office.com/en-us/article/pivottables-ebf525d5-3a1c-4718-badd-8851a27aa943?ui=en-US&rs=en-US&ad=US
16
Before you Create a PivotTable
17
Steps to Create a PivotTable
https://support.office.com/en-us/article/pivottables-ebf525d5-3a1c-4718-badd-8851a27aa943?ui=en-US&rs=en-US&ad=US
19
How to create a Pivot Table? (2/5)
3
Click ‘OK’ and your
new worksheet will
be activated.
Fields, Filters,
Column, Row, and
Values will be
displayed on new
worksheet.
20
How to create a Pivot Table ? (3/5)
4
Choose fields to add to
your Pivot Table as
needed from the Pivot
Table ‘Field List’. Selected Fields
Note: The ‘Field List’ is
only visible if you click
the cursor into the Pivot
Table itself. If you click
into a cell outside the
Pivot Table, the ‘Field
List’ will become hidden.
21
How to create a Pivot Table ? (4/5)
Select Value
5
Select value to be changed Select “Value Field Settings”
from “Values”
Select “Value Field Settings”
22
How to create a Pivot Table ? (5/5)
6
Select “Type of Calculation”
23
More than PivotTable
The below skills are also equally
important from PivotTable
PivotChart
Timeline
Slicer
Filter
24
EXAMPLE – AUTO SALES SUMMARIZATION
3
25
EXAMPLE – AUTO SALES SUMMARIZATION
Consider auto sales data, the question a decision maker might consider
in examining the data is a below.
26
DATA of AutoSales
Refer Excel File: AutoSales
28
PivotTable – Make v/s Model
Refer Excel File: AutoSales
29
PivotTable – More Combinations
Sum of Sum of Count of
Make
Sum of Sum of AmountPaid SalescCommission Model
Make
AmountPaid SalescCommission Ahmad 92500 13575 3
Audi 109000 14650 Audi 75000 11250 2
Ford 79000 7925 Ford 17500 2325 1
Toyota 129000 12230 Bill 47000 4250 2
Ford 24000 2150 1
Total 317000 34805
Toyota 23000 2100 1
Harriet 34000 3400 1
Audi 34000 3400 1
Henry 50500 4850 2
Toyota 50500 4850 2
Refer Excel File: AutoSales Kenji 55500 5280 2
Toyota 55500 5280 2
Lupe 23000 2050 1
Ford 23000 2050 1
Piego 14500 1400 1
Ford 14500 1400 1
Grand Total 317000 34805 1230
EXAMPLE – CHANGE FOCUSED SELL
4
31
Refer Excel File: SalesData
39
Refer Excel File: SalesData
43
Refer Excel File: SalesData
44
Refer Excel File: SalesData
Add Timeline
You can add Timeline to filter data using Year,
Quarter, Month or Days.
You have to select Insert Timeline from Analyze in
PivotTable.
45
Refer Excel File: SalesData
Add Timeline
You can use slider and Month to filter data.
Similarly you can use other Timelines – Year, Quarter, Days
Month
Slider
46
EXAMPLE – CONSUMER SURVEY
5
47
TiendaMía – Data Collection
Refer Excel File: SurveyWebPageDesign
The web-based business, TiendaMía.com, is interested in testing various
web designs that customers will use to order products.
The owners of TiendaMía.com hired a marketing firm to help them
conduct a preliminary survey of 30 randomly selected customers to
determine their preferences.
Each of the customers is instructed to visit a website for a measured
amount of time. The customers are then introduced to four web-page
designs and asked to respond to a series of questions. The data are self-
reported by the customers on the website as they experience the four
different webpage designs.
Hector Guerrero, “Excel Data Analysis - Modeling and Simulation”, Springer-Verlog 48
TiendaMía – Data Collection & Study
Refer Excel File: SurveyWebPageDesign
The data collected from 30 respondents regarding questions about their
gender, age, income, and the region of the country where they live are
organized.
Respondents have provided an Opinion on each of the 4 products in one
section of the data, and demographic characteristics, Category, in another.
Out of Range Response - The respondent number 13 in Table claims to be
a 19 year old female that has an income of $55,000,000 and resides in
outer space. In this case, it is relatively easy to see that our respondent is
not providing information that we can accept as true, hence this record
has to be removed from the survey response records.
49
Refer Excel File: SurveyWebPageDesign
51
Refer Excel File: SurveyWebPageDesign
Questions-1
Is there a webpage design that dominates others in terms of positive
customer response?
ANSWER -
In order to Answer above question, we need summary of data
regardless of any characteristics.
Hence answer has to be focused on how many respondents have a
preference for each webpage design?
Use COUNTIF(range, criteria) function to get summary data.
Example =COUNTIF(G4:G32, "bad")
52
Refer Excel File: SurveyWebPageDesign
Questions-1
Product 1 with 18
Count of Product
good dominates all
Product Product Product Product Total % of
1 2 3 4 Total products.
bad 11 13 14 23 61 53% Product 2 and
good 18 16 15 6 55 47% Product 3 are
116
relatively close (15
and 13) to each
Count of Product other.
Product Product Product Product Product 4 is
1 2 3 4 significantly different
bad 38% 45% 48% 79%
with only 5 good.
good 62% 55% 52% 21%
53
Refer Excel File: SurveyWebPageDesign
If question is how the two categories of gender rate their preference for
Product 1 ?
11 Males out 15 and 7 Females out of 14 gave ‘good’ opinion to
Website Design1.
We can also construct cross tabulation for other 3 Website Design
54
Refer Excel File: SurveyWebPageDesign
55
Refer Excel File: SurveyWebPageDesign
Questions 2 – Gender, Age and Income
Question 2 asks how the demographic and financial data of the
respondents relates to preferences. demographic characteristics are
represented by Gender, Age, Income, and Region.
In Question-1, we have displayed the count of respondents, but we can
include, for example, the respondents average age or the total income
STEPS
Drag Gender to Rows Average of Income
Gender bad good Total
Drag Product 1 as the
column F 61571.43 25071.43 43321.43
M 100750.00 47000.00 61333.33
Drag income to σ Values
Total 75818.18 38472.22 52637.93
Change sum of income to
Average
57
Refer Excel File: SurveyWebPageDesign
59
Refer Excel File: SurveyWebPageDesign
10
8 bad
Count
6 good
4
0
F M
Gender
60
Pivot Chart
5
4
4
3
3
2 bad
2 good
1
1
0
F M F M F M F M
east north south west
61
EXAMPLE – SALES ORDER
6
62
Refer Excel File: SalesOrders
Data
Order Date Region Rep Item Units Unit Cost Total Cost
This is sales data for a stationery 6-Jan-18 East Jones Pencil 95 1.99 189.05
company, and each row represents 23-Jan-18 Central Kivell Binder 50 19.99 999.50
an order. Data has fields as below. 9-Feb-18 Central Jardine Pencil 36 4.99 179.64
26-Feb-18 Central Gill Pen 27 19.99 539.73
Date on which the order was
15-Mar-18 West Sorvino Pencil 56 2.99 167.44
placed 1-Apr-18 East Jones Binder 60 4.99 299.40
Region in which the sale was 18-Apr-18 Central Andrews Pencil 75 1.99 149.25
made 5-May-18 Central Jardine Pencil 90 4.99 449.10
Thompso
The sales representative's name 22-May-18 West
n
Pencil 32 1.99 63.68
64
Refer Excel File: SalesOrders
Insert Formula
65
The Output - Bonus
66
Refer Excel File: SalesOrders
If I want what will be accumulated sum of sales after 2nd, 3rd .. Months We need running
total.
Right click the cell in table, Show value as, Running Total in
Pop Up box Base field will be displayed
Select year, OK
67
Refer Excel File: SalesOrders
Filter Option
Create Pivot Table for
SalesOrders. Xlsx
Drag Rep to ROWS
Drag Total Cost to σ 𝑉𝐴𝐿𝑈𝐸𝑆
Drag Item to FILTERS
Select Pen from Filter ‘Item’
It will show Data only for pen
‘Item’
Change Item in Filter, it will
show Corresponding sales for
selected item. You can select
Multiple Item and see Report.
68
Refer Excel File: SalesOrders
Slicers in Excel can quickly and easily filter pivot tables. However, using the
Report Filter we previously studied gives the exact same result.
We can use Slicer for one dimensional / two dimensional Pivot Table.
you can use a single Report Filter, connected to a slicer, to update multiple
pivot Tables.
71
Steps in Slicer Creation
1. Select a cell in the pivot table
2. On the Ribbon's Insert tab, click Slicer. (or In Analyze tab)
3. In the list of pivot table fields, add check marks for the slicer(s) you want to create.
4. Move and resize the slicers, if necessary, so they fit on the empty areas of the
worksheet
5. Click on an item in a Slicer, to filter the pivot table. Other Slicers will show related
items at the top.
72
Refer Excel File: SalesOrders
Create Slicer
73
Refer Excel File: SalesOrders
74
Refer Excel File: SalesOrders
75
Refer Excel File: SalesOrders
76
EXAMPLE – VISITORS TO CAR DEALERSHIP
7
77
date state dmaCode make model bodyStyle visitors revenue
January 1, 2017 PA 504 Honda Accord SEDAN 7 98
January 1, 2017 PA 504 Toyota RAV4 SUV 3 20
January 1, 2017 OH 536 Saturn Ion SEDAN 1 10
January 1, 2017 NC 545 Volkswagen Jetta SEDAN 1 16
January 1, 2017 NC 567 Dodge Charger SEDAN 1 10
January 1, 2017 IL 602 Ford Taurus SEDAN 4 43
January 1, 2017 TX 641 Mitsubishi Eclipse COUPE 1 10
Online Website January 1, 2017 UT 770 Mazda Mazda3 HATCHBACK 1 10
to Bring January 1, 2017 CA 803 Mercedes-Benz E SEDAN 3 72
January 1, 2017 CA 803 Mini Cooper CONVERTIBLE 2 18
Visitors to Car January 1, 2017 NC 517 Honda Civic COUPE 2 31
Dealership January 1, 2017
January 1, 2017
FL
KS
539
616
Dodge
Kia
Dakota
Sedona
PICKUP
MINIVAN
2
1
20
16
January 1, 2017 AR 693 Chrysler Sebring CONVERTIBLE 1 4
January 1, 2017 CA 862 Ford Ranger PICKUP 1 9
Refer Dataset January 1, 2017 NC 545 Jeep Wrangler SUV 4 9
January 1, 2017 NY 549 Nissan Sentra SEDAN 1 4
CarSale.xlsx January 1, 2017 NC 560 Jeep Liberty SUV 1 16
January 1, 2017 TX 623 Ford Ranger PICKUP 2 9
January 1, 2017 AZ 753 GMC Yukon SUV 2 4
January 1, 2017 AZ 753 Lexus RX SUV 2 45
January 1, 2017 CA 803 Honda Pilot SUV 5 138
January 1, 2017 MD 511 Ford Escape SUV 2 13
78
Business Problem
Each record or row of data consist of Date, Location, Car Type (make,
model, body Style) and revenue.
There are 102898 records. So It is not easy to understand dataset without
summarizing it.
Business Question we want to investigate is What kind of cars we should
focus on in next 6 months?
79
How to Solve?
In our dataset, Car type (make, model, body style) and state is qualitative type
attributes, whereas Revenue & number of visitors (facts) are quantitative.
The dmacode, date can’t be considered as quantitative because arithmetic
operations on them will be meaning less.
Important attribute is make and important fact is revenue . So create PivotTable
with make in row and revenue in Σ values. Lets sort from largest to smallest for
revenue.
Lets add visitors to Σvalues, sort from largest to smallest for visitors.
(Purpose of sorting largest to smallest so we can get important make with respect
to revenue & visitors)
80
Make, Revenue and Visitors
Values
make Sum of revenue Sum of visitors
Chevrolet 530924 331927
Ford 579861 316607
Jeep 221466 285765
Honda 416181 268159
Toyota 451873 223139
Nissan 309980 135365
GMC 87576 101047
Dodge 300277 75775
Lexus 91912 67385
Cadillac 101887 65972
BMW 167108 57674
Acura 85270 46139
Hyundai 124466 45510
85
VLOOKUP()
=VLOOKUP([@dmaCode],Table3,2,FALSE)
Gives N/A
=VLOOKUP(TEXT([@dmaCode],"000"),Table3,2,FALSE)
86
DMA Name is name of dmaCode
date state dmaCode DMA Name make model bodyStyle visitors revenue
Sum of Column
revenue Labels
January 1, January 2, January 3, January 4, January 5, January 6, January 7,
Make 2017 2017 2017 2017 2017 2017 2017
Ford 371 552 348 531 307 411 582
Chevrolet 501 362 434 260 476 534 336 Make in Row.
Toyota 226 288 473 133 358 197 278 Revenue in Sum.
Honda 654 392 408 131 416 529 287 body style in Filter.
Nissan 172 313 371 321 333 306 222 Date in column
Dodge 220 217 164 302 285 129 120
(Remember the
Jeep 170 113 92 190 115 216 240
Business problem What
Chrysler 99 177 94 222 104 48 173
BMW 315 194 29 197 143 152 197 kind of Cars we should
Volkswagen 91 16 130 52 31 124 158 focus on in next 6
Hyundai 130 116 64 136 211 62 146 months)
Mazda 49 54 24 44 28 61 70 We can add model to
Pontiac 93 64 216 74 69 131 124 next level in row, So we
Mercedes- can drill make.
Benz 183 115 26 81 71 20 62 As we have large
Cadillac 121 36 114 106 54 57 89 number of column , it
Lexus 146 88 19 232 74 20 26 will not be helpful.
GMC 91 54 47 164 14 66 8 we must group date.
Kia 50 98 66 158 73 13 100
Acura 15 56 95 10 114 259 69
91
Grouping/ Ungrouping
bodyStyle (All)
Sum of revenue Column Labels
Ford
Drag Revenue to σ 𝑉𝐴𝐿𝑈𝐸𝑆 Chevrolet
11808 69772 8742 13245 63150 31078 357781 13122 11163
9681 62935 10189 10901 61380 26549 329517 12234 7538
579861
530924
Toyota 9187 52255 8917 7131 47132 19096 282482 13490 12183 451873
Drag year, Date to Column Honda 10182 44664 9274 7636 50722 17074 258189 12241 6199 416181
Nissan 7936 35353 7271 6116 35292 15101 192612 6568 3731 309980
Drag bodyStyle to Filter Dodge 6987 37664 5727 6729 33895 21223 176993 5825 5234 300277
Jeep 5235 32995 2756 2867 27306 12308 128762 4235 5002 221466
93
bodyStyle (All)
96
Group by Quarter
bodyStyle (All)
Go to month
Heading, right Sum of revenue Column Labels
2017 Grand Total
click, select Qtr1 Qtr2 Qtr3
Group, select Row Labels Jan Feb Mar Apr May Jun Jul Aug Sep
Quarter from Ford 11808 69772 8742 13245 63150 31078 357781 13122 11163 579861
drop down Chevrolet 9681 62935 10189 10901 61380 26549 329517 12234 7538 530924
list. Toyota 9187 52255 8917 7131 47132 19096 282482 13490 12183 451873
Honda 10182 44664 9274 7636 50722 17074 258189 12241 6199 416181
Nissan 7936 35353 7271 6116 35292 15101 192612 6568 3731 309980
Dodge 6987 37664 5727 6729 33895 21223 176993 5825 5234 300277
Jeep 5235 32995 2756 2867 27306 12308 128762 4235 5002 221466
Chrysler 4066 22795 2939 3839 23939 10602 105308 3353 1922 178763
BMW 3667 26149 3143 2892 17950 8628 99568 3874 1237 167108
Volkswagen 2190 17572 1906 2308 19091 6771 83671 3727 890 138126
Hyundai 2611 13548 2543 1990 15768 5923 73445 5637 3001 124466
Mazda 2045 14894 2062 1393 12908 3687 63490 5842 1212 107533
Pontiac 2506 11020 2180 1886 13768 4623 68385 2082 106450
Mercedes-Benz 2462 14092 1211 720 11410 5055 68468 414 695 104527
97
Group by non Date fields Suppose you want to group
VAN, MINIVAN, PiCKUP some records from
bodyStyle, Say VAN, PICKUP,
2017 MINIVAN
Row Labels Qtr1 Qtr2 Qtr3 Total
Select VAN, PICKUP,
CHASSIS 953 911 2612 4476
MINIVAN (similar type)using
CONVERTIBLE 39927 30569 118882 189378 Ctrl.
COUPE 66333 72952 218526 357811
Right click select Group from
HATCHBACK 32721 32049 128908 193678
drop Down Menu.
Group1 117650 125427 485376 728453
SEDAN 286083 354389 1163536 1804008 In ROWs we have bodyStyle,
SUV 233512 248760 946481 1428753 BodyStyle2.
UNKNOWN_BO Rename bodyStyle2 as VAN-
DYSTYLE 1852 1891 2087 5830 MINIVAN-PICKUP
WAGON 25337 29916 113165 168418 This group is represented by
Grand Total 804368 896864 3179573 4880805 Group1.
We can ungroup Similarly.
98
Modify Output Values for Insights
Sum of visitors
DMA Name SUV SEDAN COUPE PICKUP MINIVAN CONVERTIBLE HATCHBACK WAGON VAN Rows:
LOS ANGELES 118869 50632 17402 5634 782 2099 1293 803 274 DMAname
NEW YORK 124954 38241 6427 3393 1877 1706 1856 1076 531
CHICAGO 74253 20951 3009 1319 1324 1227 735 648 318 Values:
PHILADELPHIA 67412 14800 1934 1996 1578 1130 932 778 156
SAN FRANCISCO-OAK-SAN Sum of Visitors
JOSE 52127 16282 6219 897 2701 914 1816 1114 404
BOSTON (MANCHESTER) 59433 13493 2167 1240 619 648 621 984 114 Column:
DALLAS-FT. WORTH 53059 11260 3909 4329 388 645 594 348 63
ATLANTA 52819 12739 3002 1237 2468 836 431 369 95
bodyStyle
WASHINGTON, DC
(HAGRSTWN) 49338 11297 2990 956 612 715 563 417 69 Sort
DENVER 42839 7926 577 800 1108 261 268 386 55
HOUSTON 43868 5194 944 1981 384 404 307 428 37
SEATTLE-TACOMA 37216 10451 1815 793 260 392 419 514 69
TAMPA-ST. PETE (SARASOTA) 33173 7483 673 850 418 634 508 287 82
PHOENIX (PRESCOTT) 34613 5083 491 741 210 378 219 206 41
MIAMI-FT. LAUDERDALE 31830 6553 965 713 333 606 442 294 171
CLEVELAND-AKRON (CANTON) 33500 3144 652 1400 491 283 279 259 64
DETROIT 31444 3915 636 712 575 209 195 290 76
99
Sum of visitors Column Labels
CONVERTI
Row Labels SUV SEDAN COUPE PICKUP MINIVAN BLE HATCHBACK WAGON VAN
LOS ANGELES 4.66% 1.98% 0.68% 0.22% 0.03% 0.08% 0.05% 0.03% 0.01%
NEW YORK 4.90% 1.50% 0.25% 0.13% 0.07% 0.07% 0.07% 0.04% 0.02%
CHICAGO 2.91% 0.82% 0.12% 0.05% 0.05% 0.05% 0.03% 0.03% 0.01%
PHILADELPHIA 2.64% 0.58% 0.08% 0.08% 0.06% 0.04% 0.04% 0.03% 0.01%
It is showing No. of visitors for
SAN FRANCISCO- DMA Names, bodyStyle.
OAK-SAN JOSE 2.04% 0.64% 0.24% 0.04% 0.11% 0.04% 0.07% 0.04% 0.02%
BOSTON To modify output, so it will
show % of average no. of
(MANCHESTER) 2.33% 0.53% 0.08% 0.05% 0.02% 0.03% 0.02% 0.04% 0.00% visitor make following changes
DALLAS-FT. WORTH 2.08% 0.44% 0.15% 0.17% 0.02% 0.03% 0.02% 0.01% 0.00%
From sum of Visitors, change
ATLANTA 2.07% 0.50% 0.12% 0.05% 0.10% 0.03% 0.02% 0.01% 0.00% to Average Visitors.
WASHINGTON, DC
(HAGRSTWN) 1.93% 0.44% 0.12% 0.04% 0.02% 0.03% 0.02% 0.02% 0.00% From drop down List select
value Field Setting.
DENVER 1.68% 0.31% 0.02% 0.03% 0.04% 0.01% 0.01% 0.02% 0.00%
HOUSTON 1.72% 0.20% 0.04% 0.08% 0.02% 0.02% 0.01% 0.02% 0.00% From this box select Show
value as ‘ % of Grand Total’.
SEATTLE-TACOMA 1.46% 0.41% 0.07% 0.03% 0.01% 0.02% 0.02% 0.02% 0.00%
TAMPA-ST. PETE
(SARASOTA) 1.30% 0.29% 0.03% 0.03% 0.02% 0.02% 0.02% 0.01% 0.00%
PHOENIX
(PRESCOTT) 1.36% 0.20% 0.02% 0.03% 0.01% 0.01% 0.01% 0.01% 0.00%
MIAMI-FT.
LAUDERDALE 1.25% 0.26% 0.04% 0.03% 0.01% 0.02% 0.02% 0.01% 0.01%
CLEVELAND-AKRON
(CANTON) 1.31% 0.12% 0.03% 0.05% 0.02% 0.01% 0.01% 0.01% 0.00% 100
TUTORIAL
8
101
Tutorial on Pivot Table Problem
For this tutorial – use book by Hector Guerrero, “Excel Data Analysis -
Modeling and Simulation”, Springer-Verlog
Students have to perform following steps
1. Read 5.3.2 PivotTable
102
103