Download as pdf or txt
Download as pdf or txt
You are on page 1of 61

Unit 5

Pivot Tables
Table creation / Table format / Functions / Pivot tables

Spanish version: Josué Aranda Ruiz / Inés Iváñez del Pozo


Translation to English: Jose Luis de la Vara / Jose María Álvarez
Pivot Tables
Unit 5
• Introduction.
• Table creation.
• Table format. Data filtering and sorting.
• Database functions. Data summary creation.
• Pivot tables.
5.1. Introduction
• Table in Excel: data set organised in rows and columns (or records).
– The first row contains the headers of the columns (fields’ names).

– The rest of columns contain data.

• They are also referred to as database lists.


– Each row is an entry record.

• They are very useful.


– They store information.

– Enable operations for easy data analysis and management.

Carlos III University of Madrid 3


5.1. Introduction
• Most relevant operations:
– Record/data sorting.

– Table content filtering according to given criteria.

– Use of formulas by adding various filtering options.

– Enable data presentation in a clear and concise manner (summary).

– Various Formatting options for all data in a table.

Carlos III University of Madrid 4


Pivot Tables
Unit 5
• Introduction.
• Table creation.
• Table format. Data filtering and sorting.
• Database functions. Data summary creation.
• Pivot tables.
5.2. Table creation

- Definition and fields


- Table data modification
- Table structure modification

Carlos III University of Madrid 6


Definition and fields
- Create a table by the following steps:
• Open the spreadsheet to work on:
File > New > Blank workbook
• Select the range of cells (with data or empty) to include in the table.
• Select Table in the tab Insert

Carlos III University of Madrid 7


Definition and fields
- The dialog box Create Table
appears

If we have previously skipped the cell


selection step, it can be done here.

If the selected range includes the heading row,


thick the box: My table has headers

- Click OK

Carlos III University of Madrid 8


Definition and fields
• After closing the dialog box:
 The Table Design appears in the ribbon tab.

 The table displays in the spreadsheet


with the selected Table Style.

Carlos III University of Madrid 9


Table data modification
• To modify or insert new data in a table, you can:
– With the keyboard directly type in new values.

– Use a Form icon

• This option is specially suitable if the table contains a lot of information.

• Insert > Form: this dialog box allows a user to easily write or show a
whole data row (or record)
– To open the data form, you must select the active table and click on the icon Form.

– It is not directly available in the ribbon options.

Carlos III University of Madrid 10


Table data modification
• To add the From icon in the quick access toolbar.
– File > Options > Customize the Ribbon
– Add the From icon from the section Commands not in the ribbon

Select the Main Tab and then


Add From icon to a new
group (which has to be
created).

Carlos III University of Madrid 11


Table data modification
Example: Books that I’ve read this month (I)
• Select the table for the form

• Click on the icon Form


– A new dialog box opens

The following buttons are available


 New: to add a new record
 Delete: to delete an active record
 Restore: it undoes the changes made
 Find Next/Find Prev: it moves to the previous/next record
 Criteria: to apply a search filter
 Close: to close the form

Carlos III University of Madrid 12


Table data modification
Example: Books that I’ve read this month (II)
• Change record data
– Select the record
– Modify the data
– If we have made some mistake
• Button Restore
– If we are happy with the changes made
• Press Enter key
– Close

Carlos III University of Madrid 13


Table data modification
Example: Books that I’ve read this month (III)
• Create a new record
– Click on button New
– Excel will display an empty record
• Fill it
– If you have made some mistake
• Button Restore
– Close

Carlos III University of Madrid 14


Table structure modification
• Clicking on the icon “Resize Table” in the Table Design tab.

• Select a new data range.


• The headings must remain at the same position.
• It only increases and decreases rows and columns.

• The rows or columns can be modified


directly by extending (or shrinking) the
table from the bottom-right corner.

Carlos III University of Madrid 15


Table structure modification
• Add row at the end of the table (to continue adding data).
• Press the TAB key from the last cell and a new row will appear.

• Add rows and columns between the existing ones.

• Tab Home > Button Insert.


or
• Select table, right click, and drop down menu
appears.

In the same way, rows and columns can


be deleted using Delete button

Carlos III University of Madrid 16


Table structure modification
• Delete data:
• Select a cell, row, or column
• Press Supr (eng: Delete) key
The selected data is deleted, but not the table structure
• Delete entire table:
• Select entire table
• Press Supr (eng: Delete) key
• Delete the table structure, but keep the table data in the sheet:
• Click Table Design > Convert to Range

Carlos III University of Madrid 17


Pivot Tables
Unit 5
• Introduction.
• Table creation.
• Table format. Data filtering and sorting.
• Database functions. Data summary creation.
• Pivot tables.
5.3. Table format. Data filtering and
sorting.

- Table format
- Table data sorting
- Table content filtering
- Exercise

Carlos III University of Madrid 19


Table format
• Easy way to use a colour combination for a table:
– Predefined Table Styles (tab Table Design)

• Select table display in Table Style Options:


– Columns or rows highlighted lines

– Text bold in the first or last column

– Font colour and background equal to the rest of cells of the spreadsheet

Carlos III University of Madrid 20


Table data sorting
• To sort data: • The headings of the table have a small arrow
on the right side.
– It is done in the same way as
• It displays a Menu for quick sorting.
sorting data in unstructured cells.

• Tab Home

• Tab Data

Possibility of sorting by color


Sorting by colour does not include the predefined colors of
the table (blues and white), but it affects the table cells that
– Data will be sorted in the table. have been explicitly colored.

Carlos III University of Madrid 21


Table content filtering
• List filtering means a selection of those records in a list that match some
criteria.

• This criteria is chosen by the user

• Excel provides two ways for list filtering:

– Using the filter (Data > Filter > Drop down menu)

– Using advanced filter (Data > Filter > Advanced)

Carlos III University of Madrid 22


Table content filtering
• Using the filter:
– Drop-down menu at the filed headings
(arrow at the right of the heading).

– Drop-down menu is enabled or disabled


in the Data tab, by clicking Filter button.

If we press on the arrow in the field Family


Name, a drop-down list shows a set of
options for filtering.

Carlos III University of Madrid 23


Table content filtering
• Using the filter:
– Drop-down menu at the filed headings
(arrow at the right of the heading).

– Drop-down menu is enabled or disabled


in the Data tab, by clicking Filter button.

If only “Anderson and Aramburu” are


marked, Excel will display all the records
whose family names are those.
Other rows will not be displayed.

Active filter
Carlos III University of Madrid 24
Table content filtering
• Using the filter (other options):
– Text filters
– Options

A window is displayed where two


text filter criteria can be selected
and decide upon the fulfilment of
one or both criteria.

Excel evaluates the selected criteria and if fulfilled,


it will display the row.
Carlos III University of Madrid 25
Table content filtering
• Using advanced filter:
– Tab Data > Sort & Filter > Advanced

– For record filtering with more complex criteria.

– The spreadsheet must have rows where the filtering criteria is specified.

• Options
 List range: specify the list of records to which filter shall be
applied.
 Criteria range: select the cell with the filtering criteria.
 Copy to: store filtering results in another place.
 Unique records only: record repetitions will not be displayed.

Carlos III University of Madrid 26


Exercise
Working with tables
1. Open the workbook Books_table.xlsx.

2. Convert the data into a table (free format, but different to the basic one).

3. Insert at least 3 other items.

4. Sort the list by the field Author.

5. Filter the books by Javier Marías.

6. Clear the filter.

7. Create an advanced filter for filtering of books whose price is below 15 €.

8. Save the changes made with the name Books_YOUR_NAME.xlsx and close
the workbook.

Carlos III University of Madrid 27


Pivot Tables
Unit 5
• Introduction.
• Table creation.
• Table format. Data filtering and sorting.
• Database functions. Data summary creation.
• Pivot tables.
5.4. Database functions.

- Database function definition


- Database function structure
- Database function types
- Data summary creation

Carlos III University of Madrid 29


Database function definition
• Database-targeted functions a predefined type of functions that can be used
on data tables.
• Database functions perform basic operations, such as Sum, Average, Count,
etc., including criteria arguments.
• To explain database functions the following file will be used:
Database_Functions.xlsx

Carlos III University of Madrid 30


Database function structure
• All the database functions follow the same structure:
– FUNCTION(data_range,field_name,criteria_range)
• data_range: range of database cells or table to manage
• field_name: field name contains the values to manage
• criteria_range: cell range contains the criteria that the records have to fulfil
– To define the conditions used in criteria_range:
• Use a dedicated part in the spreadsheet
to define conditions (preferably above
the table)
• Row 1: spreadsheet field/column names
• Row 2 and following: criteria

Carlos III University of Madrid 31


Database function types
• Function: DCOUNT
– Counts matching records in a database using criteria and an optional field. When a
field is provided DCOUNT will only count numeric values in the field.
– Example: DCOUNT(A5:E14,"Seats",A1:E2)  Result: 2

Carlos III University of Madrid 32


Database function types
• Function: DCOUNTA
– Counts matching records in a database using criteria and an optional field. When a
field is provided, DCOUNTA counts both numeric and text values when the field
value is not empty.
– Example: DCOUNTA (A5:E14,"Years",A1:E2)  Result: 2

Carlos III University of Madrid 33


Database function types
• Function: DMAX
– Returns the maximum value in a field, from a set of records that match criteria.
– Example: DMAX(A5:E14,"Benefit",A1:A3)  Result: 123

Carlos III University of Madrid 34


Database function types
• Function: DMIN
– Returns the minimum value in a field, from a set of records that match criteria.
– Example: DMIN(A5:E14,"Benefit",A1:A3)  Result: 105

Carlos III University of Madrid 35


Database function types
• Function: DPRODUCT
– Returns the product of values from a set of records that match criteria.
– Example: DPRODUCT(A5:E14,"Profit",A1:A3)  Result: 178200

9 x 11 x 10 x 15 x 12 = 178200

Carlos III University of Madrid 36


Database function types
• Function: DAVERAGE
– Gets the average in a given field for a subset of records that match criteria.
– Example: DAVERAGE (A5:E14,"Benefit",A1:B2)  Result: 112.5

Carlos III University of Madrid 37


Database function types
• Function: DSUM
– Returns the sum of values from a set of records that match criteria.
– Example: DSUM(A5:E14,"Benefit",A1:A3)  Result: 566

106 + 112 + 105 + 123 + 120 = 566

Carlos III University of Madrid 38


Database function types
• Function: DGET
– Gets a single value in a given field from a record that matches criteria.
– If no record matches the criteria, it returns #VALUE!
– If more than one record match the criteria, it returns #NUM!
– Example: DGET(A5:E14,"Brand",D1:D2)  Result: #NUM!
• If Profit = 8  Result: Renault

Carlos III University of Madrid 39


Database function types
• Function: DVAR
– Returns the variance of a sample extracted from records that match the given
criteria.
– Example: DVAR(A5:E14,"Benefit",A1:A2)  Result: 70.33

Carlos III University of Madrid 40


Database function types
• Function: DSTDEV
– Returns the standard deviation of sample data extracted from records that match
the given criteria.
– Example: DSTDEV(A5:E14,"Benefit",A1:A3)  Result: 8.11

Carlos III University of Madrid 41


Data summary creation
• Creation of subtotal function (average, sum, maximum value, standard
deviation…) enables grouping records for each table column.
• Enabling the Total Row in Table Design tab adds a new row at the
bottom of the table. In a drop-down list, several SUBTOTAL functions are
provided for each table column.

Carlos III University of Madrid 42


Data summary creation
• Example:

Row with SUBTOTAL functions

Drop-down list

Carlos III University of Madrid 43


Pivot Tables
Unit 5
• Introduction.
• Table creation.
• Table format. Data filtering and sorting.
• Database functions. Data summary creation.
• Pivot tables.
5.5. Pivot tables.

- Pivot table creation and deletion


- Filteting in pivot tables
- Average calculation in pivot tables
- Charts and pivot tables
- Exercise

Carlos III University of Madrid 45


Pivot table creation and deletion
• Pivot tables are among the most powerful Excel tools, but also among the features that many users
feel intimidated with.
• Pivot tables allow for the easy summary and analysis of large amount of data by simply dragging and
dropping columns that will be part of the report, based on different grouping criteria.
• These tables are dynamic, i.e. their content can change depending on filtering criteria, data
presentation, data source visualisation…

To explain pivot tables, the following excel file will


be used: Pivot_table.xlsx

Carlos III University of Madrid 46


Pivot table creation and deletion
• We are going to create a pivot table using this data and explore
the advantages of each feature.

• Select Pivot Table in Insert tab.

Carlos III University of Madrid 47


Pivot table creation and deletion
• The following dialog box displays.

• We can specify the place where


the data is and where we want
to place Pivot table.

We specify that we are going to select data in range of cells and that we want
to place it in a new spreadsheet.
Carlos III University of Madrid 48
Pivot table creation and deletion
• In the section Select a table or a range, select all the cells that are going
to be used (including headers).

• Press OK to continue.

A new spreadsheet opens together


with control panel (PivotTable Fields)
at the right site of the screen.

Carlos III University of Madrid 49


Pivot table creation and deletion
• From the panel PivotTable Fields, you can customise the way data will
be displayed in the pivot table.
• For example:
– ‘Reference’ displays in a row.
– ‘Month’ displays in a column.
– ‘Sum of Cost’ displays at the right-end of each row (‘Reference’) and at the bottom
of each column (‘Month’).

• Drag and drop the elements that are listed to their corresponding place
in the panel.

Carlos III University of Madrid 50


Pivot table creation and deletion
• Drag and drop:
– Reference to Rows
– Month to Columns
– Cost to Values

Carlos III University of Madrid 51


Pivot table creation and deletion
• Drag and drop:
– Reference to Rows
– Month to Columns
– Cost to Values

• Pivot table displays as:

Carlos III University of Madrid 52


Pivot table creation and deletion
• In the Pivot table created:
– Row label = ‘Reference’ Results are easier to read
– Colum label = ‘Month’ with this structure.
– Table content = ‘Sum of Cost’

Carlos III University of Madrid 53


Pivot table creation and deletion
• When a pivot table is created, the PivotTable Analyze tab appears.

• The panel on the right-site remains open as long as mouse cursor is in the
pivot table.

• To delete a pivot table:

– Select entire pivot table and press the Supr (Eng: Delete) key.

Carlos III University of Madrid 54


Filtering in pivot tables
• It is useful to filter results to see only the data we are interested in at a given
moment.

– Example: Large amount of data

• The main fields in the right-site panel and


the labels in the table filtering through a
drop-down list.

• Pressing an arrow at Column Labels, the


drop-down list displays.

Carlos III University of Madrid 55


Filtering in pivot tables
• Column Labels, the drop-down list displays the content of ‘Month’. Given
month can be filtered by a checkbox.

• If January and February are selected, the other months will disappear from the
table, but the data will not be lost.

• To close the box saving the changes, press OK. If you do not want to keep the
modifications, press Cancel.

Carlos III University of Madrid 56


Average calculation in pivot tables
• When a pivot table is created, Excel generates a sum (at the end of each row
and each column) by default. This can be to modified by introducing other
functions, e.g., maximum, minimum, or average value.

• Select any cell of the pivot table, right-


click and the following menu displays.

• Setting field value…

Carlos III University of Madrid 57


Average calculation in pivot tables
• In the menu open:

(1) Summarize Values By

or

(2) Value Field Settings

and select among different functions: Sum (default), Count,


Average, Product, etc.

• Value Field Settings is also available via PivotTable


Analyze tab > Active Field > Field Settings.

Carlos III University of Madrid 58


Charts and pivot tables
• To create a chart for a pivot table,
go PivotTable Analyze > PivotChart.

4000

• The dialog box “Insert Chart” is 3500

3000

displayed. 2500
Junio
Mayo
Abril
2000
Marzo
1500 Febrero
Enero
• Choose a suitable chart. 1000

500

0
72 90 100 135 150 160 210 212 250 300 480

Carlos III University of Madrid 59


Exercise
Working with pivot tables
Report delivery
From the file Movies_pivot_tables.xlsx:
o Create a pivot table to determine, for each supplier and each year, how
many movies have been released, the income generated, and total
number of cinemas.
• Note: for a better visualisation, move the values from the columns
area to row labels.
o Visualise the total income generated by all their movies and the average
number of cinemas (only two decimals), of the supplier Universal in 2014
o Create a chart of the pivot table where the sum of the total income is
show for each supplier and each year.
• Note: select bar chart.

Carlos III University of Madrid 60


Unit 5

Pivot Tables

Table creation / Table format / Functions /


Pivot tables

Spanish versión: Josué Aranda Ruiz / Inés Iváñez del Pozo


Translation to English: Jose Luis de la Vara / Jose María Álvarez

You might also like