Pivot Tables

What are Pivot Tables?

Pivot Tables are aggregations of groups of values from more extensive data sets (cell ranges, Excel Tables, external databases, etc.) that contain structured data.

Pivot tables are objects superimposed over regular cells. They will usually contain row, column, and value fields. Those can easily be added, removed, rearranged, or modified.

While Pivot Tables can be used for many purposes, their primary use case is to help us quickly slice and analyze large and/or unknown data sets and recognize patterns and locations of desired information.

 

How to create or remove a Pivot Table

Consider the following example:

excel data cell range

 

Here, we have a large amount of structured data in our cell range. We can do some basic analysis using filters, but given the large amount of rows, this is not very effective.

However, we can insert a Pivot Table by first selecting that data and then clicking on the Pivot Table button located on the Insert tab:

excel insert pivot table

Given that we have previously selected our data, our data source, in this case cell range, is already defined. Had we not done so, we would have to select it in this step, either from a Table/Range, external data source, or Data Model.

By default, new Pivot Tables are inserted into new worksheets, but we can also specify an already existing location within a workbook.

 

Our newly inserted Pivot Table will appear in a new worksheet, and if we click on it, to the right, Pivot Table Fields window will appear, with two new tabs, PivotTable Analyze and Desing also appearing:

excel new pivot table

While the Design tab will contain commands for changes in the appearance of the Pivot Table, the PivotTable Analyze will contain commands for everything else, including the command that toggles the PivotTable Fields window on and off.

 

We can remove unwanted Pivot Tables by selecting all the cells superimposed by the Pivot Table and deleting them:

excel delete pivot table

Alternatively, we can also use copy and paste to remove the table while keeping the generated aggregations.

 

How to change Pivot Table Data Source

If our source data updates, we can update our Pivot Table by using PivotTable Analyze / Refresh / Refresh.

If we want to change the source data, we can do that by using the Change Data Source command located next to the Refresh command:

excel pivot table change data source

 

Pivot Table Fields: Values

If our source column contains values, it can be added to the Pivot Table Values area:

excel pivot table add values

For columns containing numbers, the sum of the values is the default.

For columns containing text, the count of the values is the default.

 

This can be (if applicable) changed in the Value Field Settings:

excel pivot table value field settings summarize values by

Multiple fields can be added to Values. The same field can be added to Values multiple times!

 

Here, we have again added the same field to Values:

excel pivot table value field settings show values as

As visible, under Show Values As, we can also set up some calculations – % of Grand Total, % Of, Difference From, Rank, etc. In this example, we have changed this from No Calculation to % of Grand Total.

We have also renamed this value to Grand Total – we have done this by entering a value in Custom Name.

We can also change the applied number format by using the Number Format command. If needed, using this command, we can also apply a custom number format; for example, our numbers could be formatted to be shown as thousands or millions.

 

Pivot Table Fields: Rows and Columns

We can drag items from Fields to Rows and Columns in whatever order it suits us:

excel pivot table rows

Once dragged, they can also be (re)arranged as we want.

If we move invoice_paid to the beginning, our PivotTable also restructures:

excel pivot table rows move to beginning

 

We can also freely move our fields between Rows, Columns, Filters and Values.

In this example, we have moving our invoice_paid field to Columns:

excel pivot table rows move to columns

 

With Rows and Columns, we will have Field Settings command available:

excel pivot table rows field settings

If we apply changes to this particular filed highlighted here, our pivot table will now look like this:

excel pivot table rows repeat item labels, show items in tabular form, no subtotals

 

Pivot Table Fields: Filters

We can move already used or previously unused fields to Filters:

excel pivot table filters

 

We can filter either by selecting a single item or by selecting multiple items:

excel pivot table filters select item, select multiple items

 

We will have even more filtering options available if we apply filters directly on rows (or columns):

excel pivot table filters rows columns

We can either filter directly from the pop-up window (those are Label Filters), or we use the Label Filters command for more options.

We can also apply value filters—those are also applied to the selected field we are filtering. For example, given that we are filtering the field salesforce, we can apply a filter that shows us only teams with the sum of values greater than the certain amount.

 

Sorting is also available here:

excel pivot table sorting rows columns

By positioning ourselves in the selected field or selecting that field from the drop-down menu, we can sort that field.

Not only that, but we can also sort that field by values.

As shown in this example, we are sorting the region field by Sum values in descending order.

 

Calculated Items & Calculated Fields

Calculated items are created by applying formulas onto items already existing in source columns.

If we position ourselves into a Pivot Table row or a column, the Insert Calculated Item option will become available:

excel pivot table insert calculated item

For example, we can create a new America item from North and South America:

excel pivot table insert calculated item formula

However, those values are by default duplicated now, and we have to filter out North and South America in order for our totals to be correct:

excel pivot table insert calculated item filter out

 

We can use Calculated Fields to perform basic calculations on existing columns containing values.

We can position ourselves anywhere in a Pivot Table, and the option to Insert Calculated Field will be available. In the next example, we will calculate a commission amount charged against our invoices:

excel pivot table insert calculated field

We can also perform basic calculations with multiple (existing in the source data or calculated) columns. In the next example, we will subtract calculated commissions from our invoices:

excel pivot table insert calculated field from multiple columns

The result of those calculations will look like this:

excel pivot table multiple calculated fields

 

Pivot Table Slicers

Slicers provide buttons that you can click in order to filter Pivot Tables. This quick filtering is especially useful when Pivot Tables are used as a reporting tool; other than enabling filtering, it also instantly visualizes what exactly is currently filtered.

We can insert one or more slicers under PivotTable Analyze, Insert Slicer:

excel pivot table insert slicers

In the following example, no team is filtered out, but paid invoices are filtered out. I.e., we are showing only the data for unpaid invoices:

excel pivot table active slicers

 

When a Slicer is active, a new tab, Slicer, also appears:

excel pivot table slicer settings

Here, we can further set up our slicers.

 

Pivot Table Timelines work much like Slicers, only they are intended for filtering dates.

Leave a Reply