Excel 2007 FDA 2
Excel 2007 FDA 2
Excel 2007 FDA 2
Part 2: PivotTables
INFORMATION TECHNOLOGY SERVICES
California State University, Los Angeles
Version 1.1 Spring 2009
Contents
Introduction ................................................................................................................................... 2
Scenario.......................................................................................................................................... 2
Scenario
Many companies and organizations use Excel to deal with numeric data and analyze it from a
different perspective. A bank report is one of the examples which show how a dataset is analyzed
based on multiple conditions. For instance, it is used to show the account balance, the account
average balance, the number of accounts, and the open date of the accounts in each branch. Also,
it seeks to compare the data between branches. In addition, the use of different kinds of graphs
provided in Excel enhances the analysis of the data as well as its appearance. Therefore, this
handout will demonstrate how the user can customize a bank report appropriate to the purpose,
by employing the PivotTable or PivotChart wizard. Furthermore, it will help the user to
understand how to perform numerous calculations with ease in the PivotTable and PivotChart.
The dataset of Part two includes several data fields such as bank branch, account type, customer
type, and open date, which demonstrate the relevant data for a bank report. The bank branches
include Central, Northwest, and Westside. There are three types of bank accounts which include
the CD (Certificate of Deposit), Checking, and Saving Accounts. The dataset categorizes the
customers into four types, such as Personal, Personal VIP, Corporate, and Corporate VIP
depending on their current balance, average balance, and other factors affecting their credit for
the past five years. In this dataset, the average balance and other factors will not be displayed for
the users to simplify creating a PivotTable report. Also, the dataset shows only the open dates of
accounts from 2001 to 2005, but the date items can be grouped by months, quarters, and years in
the PivotTable and PivotChart Reports.
Creating a PivotTable
A PivotTable, also called PivotTable Report, is a summary table which uses two-dimensional
data to create a three-dimensional table based on multiple conditions that have intersecting
points. PivotTable can summarize large amounts of information in a small amount of space. The
advantage of the PivotTable is its flexibility to view the details that make up the total number
and its ease in performing numerous calculations without typing a formula. A PivotTable Report
is created using the PivotChart Wizard, which walks the user through the step-by-step process.
3. The range of data is automatically given as; $A$1:$E$200. It resulted from the position
of the cursor in the worksheet before starting the Create PivotTable dialog box.
Otherwise, click on the edit box and select a range of data to use from $A$1:$E$200.
4. Select New worksheet under Choose where you want the PivotTable report to be
placed.
5. Click the OK button. “Sheet1” is automatically created (see Figure 2).
The following describes the four areas that are available for adding a field (see Figure 3):
1. Report Filter: Creates a drop-down menu above the table to analyze a specific item
from the field, such as a selected branch.
2. Row Labels: Applies a vertical format to the table, summarizing the data from top
down. The row drop area lists each item in the field down the left side of the PivotTable.
3. Column Labels: Applies a horizontal format to the table, summarizing the data from
left to right. The column drop area lists each item in the field across the top of the
PivotTable.
4. Values: The data drop area is the summary of the numbers. This area adds, counts, or
creates other analytical functions against the data dropped here.
To add fields into the PivotTable layout under the PivotTable Field List dialog box:
1. Click the Branch field. Drag and drop it into the Report Filter drop area.
2. Click the Account Type field. Drag and drop it into the Row Labels drop area.
3. Click the Customer Type field. Drag and drop it into the Column drop area.
4. Click the Balance field. Drag and drop it into the Values drop area (see Figure 4).
NOTE: Another way of changing the summary function is by right-clicking cell A3 and then
choosing Value Field Settings… from the drop-down menu.
Figure 11 – Adding a New Field Figure 12 – Open Date Field Added to PivotTable
NOTE: Different field items can only be places in certain areas. See Table 1 for the list and
description of the icons that appear when dragging a field over the PivotTable.
NOTE: As an alternative way, point the cursor on a data field cell. The pointer becomes a four-
headed arrow. Drag the data field to the desired position.
APPLYING AUTOFORMATS
In Excel, it is possible to manipulate and format a PivotTable by changing the font, point size,
colors, etc. This section shows how Excel can automatically apply a preset style to a new
PivotTable.
2. Click on the Analyze tab. Click on the Field list button under Show/Hide group.
3. Drag the Account Type field to the Axis Fields (Categories) list box under the Years field
(see Figure 25).
FORMATTING A PIVOTCHART
Formatting changes the appearance of the chart. The formatting options available depend on the
selected object. For example, if the chart area is selected, Excel allows the patterns, fonts, and
chart area properties to be changed. The user can also use the buttons on the Formatting toolbar
to format text, add values, data points, and data series, as well as fill colors and patterns.
To format a chart title using the formatting button on the Chart toolbar:
1. Open the file “PivotChart2.xlsx” from the student data drive.
2. Click on the worksheet “Chart1” to begin formatting.
3. Click on the chart title once to select it. The PivotChart Tools contextual tabs appear.
Click on the Format tab.
4. Click on the Chart Area drop-down arrow to select an object to
format. Click on the Format Selection button (see Figure 26). The Format Chart Title
dialog box appears.
5. Select the Fill tab. Change fill color and type of fill as desired (see Figure 27).
4. Click Desktop in the Look in: drop-down list and select the file, “PivotTable”.
Lookup Functions
A lookup function essentially returns a value from a table in a range by looking up another value.
A common telephone directory provides a good analogy. To find a person’s telephone number,
the name must first be located, and then the corresponding number can be retrieved. This is
essentially how a lookup function works.
This section discusses various techniques that can be used to look up a value in a table. Excel has
three functions (LOOKUP, VLOOKUP, and HLOOKUP) designed for this task.
LOOKUP
LOOKUP has two different syntaxes. One is used to return a value from a single column or row
and the other is used to return a value from a specified table array. Either syntax can be used.
lookup_vector: The single column or row of values to look up and return (if result_vector is
not specified), which can be text, numbers, or logical values.
NOTE: The values in a lookup_vector must be sorted in ascending order; otherwise, LOOKUP
may not return the correct value.
[result_vector]: (optional) The single column or row of values to return if specified. The range
size must be the same as the size of the lookup_vector.
LOOKUP will compare the lookup_value with each value in the lookup_vector and stop at the
position of the largest value that is smaller than the lookup_value. It will then return the value
stored in the same position it stopped on from the result_vector. This is the reason why the
size of the result_vector must be identical to the size of the lookup_vector.
NOTE: Absolute references, $G$4:$G$8, $H$4:$H$8, are needed since the formula needs to be
copied. Another way to do this is by assigning a name for the range and using that name in the
argument.
LOOKUP(lookup_value, array)
Similar to the above syntax, the only difference is that the lookup_vector and result_vector are
now combined together into a table array entry. This is the easiest syntax to use.
Consider the previous example once more, this time by entering a table array instead.
1. Type the formula [=LOOKUP(D4, $G$4:$H$8)] into cell E4.
2. Copy the formula into range E5:E13. The result is exactly the same as the previous
example, but only two arguments are required in this syntax instead of three arguments
(see Figure 39).
VLOOKUP
VLOOKUP searches for a value in the leftmost column of a table, and then returns a value in
the same row from a specified column in the table. Table values must be sorted by the left
column.
For example, to find the phone number and e-mail of a student within a range of data:
1. Select the “VLookup” worksheet. A table is listed in the range A3:C11 with the columns
“NAME”, “PHONE”, and “EMAIL”.
2. Type [Mary] into cell E6. This will be the value to be searched in the table.
3. Type the formula [=VLOOKUP(E6, A3:C11, 2)] into cell F6. The result is the phone
number corresponding to “Mary” (see Figure 40).
4. Type the formula [=VLOOKUP(E6, A3:C11, 3)] into cell G6. The result is the e-mail
address corresponding to “Mary”.
5. Type a different value into cell E6 and observe the VLOOKUP values change
accordingly.
HLOOKUP
HLOOKUP works similar to VLOOKUP. It searches for a value in the topmost row of a table
and returns values in the same column and from a specified row in the table. The table values
must be sorted by the top row.
For example, to find the phone number and e-mail of a student within a range of data:
1. Select the “HLookup” worksheet. A table is listed in the range B1:J3 with the rows
“NAME”, “PHONE”, and “EMAIL”.
2. Type [Mary] into cell C7. This will be the value to be searched in the table.
3. Type the formula [=HLOOKUP(C7, B1:J3, 2)] into cell D7. The result is the phone
number corresponding to “Mary” (see Figure 41).
4. Type the formula [=HLOOKUP(C7, B1:J3, 3)] into cell F7. The result is the e-mail
address corresponding to “Mary”.
5. Type a different value into cell C7 and observe the HLOOKUP values change
accordingly.