Analyse Data With Excel Tables
Analyse Data With Excel Tables
2
Analyse Data with Excel Tables: Master Excel Tables to Manage and Analyse your Data
1st edition
© 2021 Marcus Syben & bookboon.com
ISBN 978-87-403-3843-0
3
ANALYSE DATA WITH EXCEL TABLES Contents
CONTENTS
About the author 10
Preface 11
1 Introduction 12
1.1 Who this Book is For 12
1.2 What this Book Includes 12
1.3 How to Download the Sample Workbooks 12
4
ANALYSE DATA WITH EXCEL TABLES Contents
5
ANALYSE DATA WITH EXCEL TABLES Contents
6
ANALYSE DATA WITH EXCEL TABLES Contents
TABLE OF FIGURES
Figure 1: The Go To Dialog 16
Figure 2: Named Range list 16
Figure 3: Cell reference using a regular list 17
Figure 4: Cell reference using an Excel Table 17
Figure 5: Chart using regular list 17
Figure 6: Chart using regular list does not include new rows 18
Figure 7: Chart using an Excel Table 18
Figure 8: Chart using Excel Table includes new rows 18
Figure 9: Tables have slicers 19
Figure 10: Tables have calculated columns 19
Figure 11: Tables have a Total Row 20
Figure 12: Table Total Row uses the SUBTOTAL function 21
Figure 13: Table column headings are always visible 21
Figure 14: Column headings when your Table headings are visible 21
Figure 15: Table preformatted styles 22
Figure 16: Different parts of a Table 23
Figure 17: The Create Table dialog 24
Figure 18: Total Row drop-down list of functions 24
Figure 19: Toggle Filter Arrows on Tables 26
Figure 20: Table sizing handle 26
Figure 21: Enter heading text over multiple lines 27
Figure 22: Table must have unique column names 28
Figure 23: A plain list to convert to a Table 29
Figure 24: Confirm the area of your Table 30
Figure 25: New Table with the default Table Style 31
Figure 26: Formatting your Table 31
Figure 27: Format As Table from Home ribbon tab 32
Figure 28: Format As Table Styles 32
Figure 29: Format As Table, confirm the Table area 33
Figure 30: Format As Table with selected Table Style 33
Figure 31: Quick Analysis Menu - Display your list 34
Figure 32: Quick Analysis Menu - display shortcut menu 35
Figure 33: Quick Analysis Menu - select Table Style 36
Figure 34: Keyboard shortcut - display your list 37
Figure 35: Keyboard shortcut - confirm Table range 37
Figure 36: Table Names - standard vs custom 38
Figure 37: How to name your Table 39
Figure 38: Change the Table Style 42
7
ANALYSE DATA WITH EXCEL TABLES Contents
8
ANALYSE DATA WITH EXCEL TABLES Contents
9
ANALYSE DATA WITH EXCEL TABLES About the author
Marcus has been involved in everything Excel; from fixing formulas to developing complex
multi-user solutions. Excel based solutions leverage your existing software investment to
save time, save money, reduce stress and reduce the operation risk inherent in most manual
processes.
Prior to Excel consulting, Marcus worked as a corporate trainer teaching frustrated and
time strapped office workers and business people how to get more out of Excel, Word,
PowerPoint and Access. Marcus also actively answers Excel related questions on Quora and
maintains an Excel related website & blog.
If you would like to get in touch to learn how Excel automation can save dramatically you
time and reduce your costs, you can find Marcus here:
Website https://myexcelgenius.com/about/
10
ANALYSE DATA WITH EXCEL TABLES Preface
PREFACE
In a recent survey of over 1,300 global businesses commissioned by Splunk, over 80%
stated that data skills were required for promotion in their companies. Meanwhile, Forrester
Research claims data is “the new currency of business.”
It should come as no surprise that one of the more common uses of Excel is to manage,
manipulate and analyse data. Excel’s data-centric functionality extends far enough that
many people use Excel to manage tables of data in lieu of dedicated database applications
like MS Access.
However, most of these users – particularly those wanting to analyse data – simply aren’t
leveraging Excel to its fullest potential. They either try cumbersome workarounds, inefficient
formulas or simply don’t achieve the results they are trying to achieve.
Excel allows you to convert a list or tabular data to a dedicated “Table”. This provides
additional functionality and superior formula handling to manage and analyse your data
more intuitively and with greater flexibility.
This book covers the features and functionality of Excel ‘Tables’ so you can better manage
and analyse your data. You will discover how much easier it is to manage, format, sort,
filter and more-intuitively analyse your data than ever before.
11
ANALYSE DATA WITH EXCEL TABLES Introduction
1 INTRODUCTION
This book assumes you’re an intermediate or advanced Excel user who needs to manage
or analyse data in Excel. You want to learn faster, more effective ways to manage, format,
manipulate and analyse your data.
This book assumes you know how to enter formulas and are familiar with some worksheet
functions such as COUNTIF, SUMIF and VLOOKUP. However, this book also assumes no
familiarity with Excel Tables. We will start from the beginning and progress to advanced features.
The images in this book were taken from Excel 365 for Windows. While the keyboard
shortcuts listed are for Windows, many are also included for Mac.
12
ANALYSE DATA WITH EXCEL TABLES Introducing Excel Tables
Excel Tables are a tabular lists of data which Excel gives special treatment for the specific
purpose of managing and analysing your data. By defining a tabular list as a Table, Excel
provides special tools and features to make managing and analysing your data simpler and easier.
Headings
With a regular list, if you want a header row you must manually enter it yourself. You
may also use multiple rows as headers and your column names do not have to be unique.
With a Table, Excel creates a single header row for you, although you can easily hide it. To
provide structure and uniformity, each column heading must be unique.
Data
With a regular list, you can enter data wherever you like – Excel provides no constraints
or boundaries. This often results in unmanageable data or erroneous results.
With a Table, Excel is ‘aware’ of the boundaries of your data. As such, Excel assists in
maintaining data quality by actions such as copying formulas down to new rows as you
type, enforcing consistency in formulas on calculated columns and automated formatting.
13
ANALYSE DATA WITH EXCEL TABLES Introducing Excel Tables
Formulas
With a regular list, unless you apply Named Ranges, formulas use standard cell references.
With very large Tables, it become difficult to know which column your formulas are
referencing. If you’ve ever entered a VLOOKUP formula against a list with dozens (or
hundreds) of columns, you will know what I mean. Here’s an example:
With a Table, Excel uses ‘structured references’. These refer to the sections of Table such as
the column heading names. This provides more intuitive and robust formulas. Excel also
works hard to keep the formulas in the calculated columns of a Table consistent.
Totals
With a regular list, if you want column totals, you must manually add them yourself. Unless
you use specific worksheet functions, filtering may affect the accuracy of your totals. That
is, when you filter your list, most functions – like SUM – will still include the filtered
(that is, hidden) values.
With a Table, Excel creates a Total Row for column totals. Excel uses the SUBTOTAL
function which only includes visible rows so if you filter your Table, the totals reflect this.
Formatting
With a regular list, you must apply all the formatting manually. If you would like every
alternate row shaded – a common requirement – you must do this manually. With a Table,
Excel provides automatic formatting which includes formatting alternate rows. The formatting
is consistent across the entire Table and can be easily customised.
14
ANALYSE DATA WITH EXCEL TABLES Top 10 Benefits of Excel Tables
3 TOP 10 BENEFITS OF
EXCEL TABLES
There’s a host of benefits to using Excel Tables rather than static lists of tabular data. Some
of these benefits may make you aware of Excel features you didn’t know existed.
You can quickly create an Excel Table with around 4 mouse clicks, or even faster with a
keyboard shortcut. Tables even come with a dedicated ribbon tab called Table Design which
appears when you select a Table.
15
ANALYSE DATA WITH EXCEL TABLES Top 10 Benefits of Excel Tables
If you’re familiar with Excel’s Go To dialog (ctrl+G in Windows or ^+G on the Mac), it
not only displays cell references and Named Ranges, but also a list of all your Excel Tables:
Alternatively, you can quickly jump to a Table via the Named Range list:
Even better, any formulas which reference your Table will automatically include the new
columns and rows you add. There’s no need to update the cell references, update named
ranges or reference entire columns in your VLOOKUP formulas.
For example, if you have a sum formula adding a column, such as ‘Billion Tons’ (below)
and then add a new line for Russia, you will need to update the SUM function manually.
16
ANALYSE DATA WITH EXCEL TABLES Top 10 Benefits of Excel Tables
In contrast, formulas which reference Tables use ‘structured references’. These use named
sections of your Table. Any new rows you add to your Table are automatically included in
your formula.
The same principle applies to charts. Charts whose data comes from a regular range of cells
will not update when new rows or columns of data are added.
For example, imagine you created a chart based on 3 rows of data in a regular list:
If you later add another row of data, it would not show in your chart because your chart
uses specific cell references.
17
ANALYSE DATA WITH EXCEL TABLES Top 10 Benefits of Excel Tables
Figure 6: Chart using regular list does not include new rows
Instead, you can create a chart based on 3 rows of data in an Excel Table:
As the chart now uses the structured references of your Table, any new data added to the
Table is automatically added to the chart:
Unlike the filter dropdowns, Slicers also makes it visibly obvious which columns are filtered
and by what values.
18
ANALYSE DATA WITH EXCEL TABLES Top 10 Benefits of Excel Tables
19
ANALYSE DATA WITH EXCEL TABLES Top 10 Benefits of Excel Tables
For example, if your Table is called ‘Sales’, the formula ‘=Sales’ will return the entire Table.
Meanwhile ‘=SUM(Sales[Product])’ will sum the entire ‘Product’ column in the Table
called ‘Sales’. You don’t need to know which column ‘Product’ is in or which worksheet
the Table is in.
20
ANALYSE DATA WITH EXCEL TABLES Top 10 Benefits of Excel Tables
One benefit of SUBTOTAL is that the calculated values will still be correct if you filter
or slice your Table. In contrast, functions like SUM() include hidden rows that have been
filtered out.
This only happens provided you have one or more cells selected in the Table.
If you scroll past the Table or click outside of the Table, the worksheet column headers
revert back to alphabetical labels (A, B, C etc.)
Figure 14: Column headings when your Table headings are visible
21
ANALYSE DATA WITH EXCEL TABLES Top 10 Benefits of Excel Tables
The Table Format option can be accessed from the Home tab as well as the Table Design
tab. Table Style options also let you nominate which section of the Table you want to format.
The common solution is to use an avalanche of VLOOKUP functions to collate the data
you need into a single view.
Alternatively, you can ‘connect’ your Tables and produce a report that seamlessly combines
them, as easily as if your data were a single Table. You’ll learn about this advanced feature
in Chapter 13, Working with Multiple Tables.
22
ANALYSE DATA WITH EXCEL TABLES Anatomy of an Excel Table
n Heading Row
When you create a Table, Excel ‘guesses’ if the first row has headings. If so, Excel designates
the first row as the ‘Heading Row’. This means you can reference it in formulas using the
column heading names.
If Excel guesses incorrectly, simply tell Excel by removing or adding the check or tick from
the Create Table dialog box:
23
ANALYSE DATA WITH EXCEL TABLES Anatomy of an Excel Table
o Rows
When you create a Table, Excel applies the default Table Style. The style is designed to
make larger Tables easier to follow, for example, by shading alternate rows.
The alternate row shading, or ‘banding’, can also be customised using a combination of
borders and shading. Alternatively, the shading can be removed altogether.
p Total Row
Excel Tables give you the option of including a ‘Total Row’. The Total Row allows you to
provide a quick summary of your data with a selection of aggregations you can select from
a drop-down list.
By default, Excel uses the SUBTOTAL function which ignores hidden rows when you filter
your Table. You can easily change this to suit your needs.
24
ANALYSE DATA WITH EXCEL TABLES Anatomy of an Excel Table
q Columns
There are several useful features of columns in an Excel Table.
When you enter a formula anywhere in a given column, Excel copies that formula down
the entire column. This helps ensures consistency in your formulas.
Also, to add a new column, simply start typing in the first blank column to the right of your
Table. Excel will automatically expand the size of your Table to include the new column.
Any formulas which reference your Table will include this new column.
r Filter Arrows
Filter Arrows are perhaps the more typical way to filter Excel data. Excel automatically
adds the Filter Arrows when you create a Table. You can easily remove the Filter Arrows
by unchecking Filter Button on the Table Design tab.
25
ANALYSE DATA WITH EXCEL TABLES Anatomy of an Excel Table
s Data
This is the bulk of your Table where your data lives – sandwiched between your Heading
Row and Total Row.
t Resize Handle
At the bottom-right corner of your Table is a small ‘handle’:
Holding your mouse cursor over this ‘handle’ will display a double-sided arrow. When you
click-and-hold the arrow, you can then drag your mouse to resize your Table.
Note, however, that you may only change the number of columns or rows with each resize.
To increase the number of columns and rows thus requires two steps: increase the number
of columns first and then the number of rows (or vice-versa).
26
ANALYSE DATA WITH EXCEL TABLES Anatomy of an Excel Table
To enter heading text over multiple lines in a cell, press ALT+ENTER wherever you want
to enter a new line within a cell. In Excel for Mac, press ^+Ⴆ+ RETURN.
Excel will add a sequential number after any repeated column headings in your Table.
27
ANALYSE DATA WITH EXCEL TABLES Anatomy of an Excel Table
Self-Contained
Each Table must be self-contained. That is, any given Table cannot overlap with another
Table.
Array Formulas
If you are familiar with ‘array formulas’, be aware that you may only enter single-cell array
formulas in Tables. Multi-cell array formulas are not currently supported in Tables.
28
ANALYSE DATA WITH EXCEL TABLES Creating Excel Tables
Example Workbook
You can follow the examples in this section with this workbook:
29
ANALYSE DATA WITH EXCEL TABLES Creating Excel Tables
If your Table does not have headings in the first row but Excel has guessed that is has,
simply remove the check mark from the My Table has headers option.
Once you click OK, Excel designates the area as a ‘Table’, names it and formats it with
the default Table Style.
30
ANALYSE DATA WITH EXCEL TABLES Creating Excel Tables
31
ANALYSE DATA WITH EXCEL TABLES Creating Excel Tables
32
ANALYSE DATA WITH EXCEL TABLES Creating Excel Tables
Once you click OK, Excel designates the area as a ‘Table’ and formats it with the Table
Style you selected earlier.
33
ANALYSE DATA WITH EXCEL TABLES Creating Excel Tables
34
ANALYSE DATA WITH EXCEL TABLES Creating Excel Tables
35
ANALYSE DATA WITH EXCEL TABLES Creating Excel Tables
As you hover your mouse cursor over the Table option, Excel will display a ‘preview’ of
the Table.
Once you click the Table button, Excel will immediately create your Table.
Quick Tip
The Windows keyboard shortcut to display the Quick Analysis menu is ctrl+Q.
36
ANALYSE DATA WITH EXCEL TABLES Creating Excel Tables
Quick Tip
Excel for Windows actually has two keyboard shortcuts to create a Table – CTRL+L does
the same thing a CTRL+T.
37
ANALYSE DATA WITH EXCEL TABLES Naming an Excel Table
Once you have more than a few Tables, it becomes difficult to tell them apart.
Giving your Tables concise names will make them more intuitive, easier to manage and
make your formulas far easier to read.
38
ANALYSE DATA WITH EXCEL TABLES Naming an Excel Table
This is why it’s generally best practice to name your Table is as soon as you create it, as
your Table will already be selected and the Table Design tab will be active.
39
ANALYSE DATA WITH EXCEL TABLES Naming an Excel Table
No Spaces
You may not use spaces to separate words. However, you can use an underscore character
(_) or a period (.) as word separators.
So, for example, while you can’t name a Table ‘Annual Sales’ you could name it ‘Annual_Sales’
or ‘Annual.Sales’
Unique
Your Table name must be unique within a workbook. That is, it cannot conflict with any
other names (such as named ranges or other Tables) in the current workbook.
Remember also, Table names are not case sensitive. ‘Sales’ is the same as ‘SALES’.
40
ANALYSE DATA WITH EXCEL TABLES Naming an Excel Table
Remember though, your Table name will appear in formulas. If your Table names are too
long, it can complicate your formulas making them difficult to read.
Meaningful
And finally, while it’s not a ‘rule’, keep your Table names meaningful. This will make them
more intuitive and easier to work with; especially in your formulas.
41
ANALYSE DATA WITH EXCEL TABLES Formatting Excel Tables
Each time you create a Table, Excel formats your Table using the default Table Style. The
specific ‘look and feel’ of the default style will depend on the document theme you are using.
Example Workbook
You can follow the examples in this section with this workbook:
42
ANALYSE DATA WITH EXCEL TABLES Formatting Excel Tables
q Select A Style
From the list of Table Styles select a style to apply.
As you move your mouse cursor over any style, Excel will temporarily format your Table
with the highlighted style as a ‘preview’. The style will not be applied until you click the
style from the list.
The steps are identical to those above in To Change the Table Style, except for step 4. Instead,
select Clear from the bottom of the list of Table Styles.
43
ANALYSE DATA WITH EXCEL TABLES Formatting Excel Tables
Under the Table Design tab, the Table Style Options group allows you to toggle (that is,
turn on or off) a handful of formatting attributes.
The exact impact each option has will depend on the style you have chosen and the
document theme you are using. The best way to discover what each option does is to simply
experiment and try each option.
For this example, we’ll assume you want to apply the below colour scheme to your table:
44
ANALYSE DATA WITH EXCEL TABLES Formatting Excel Tables
This step is not mandatory, but if you create several styles, a meaningful name is more
helpful than ‘Table Style 1’.
o Set as Default
Check this box if you want to use this new style from now on (in this workbook). The
next time you create a new Table in this workbook, Excel will apply this style rather than
the default style.
45
ANALYSE DATA WITH EXCEL TABLES Formatting Excel Tables
q Select a Colour
You can select a Header Row colour from the palette, or ….
r Define a Colour
… click More Colors and enter a Custom colour by entering the Red-Green-Blue (RGB)
or Hexadecimal (Hex) values.
In our example, enter 74 for Red, 75 for Green and 79 for Blue. Then click OK and OK
again to close the colour and format dialogs.
46
ANALYSE DATA WITH EXCEL TABLES Formatting Excel Tables
As you can see, the process is simply selecting each Table Element you want to format,
clicking the Format button to display the Format Cells dialog and selecting the formatting
options you want.
47
ANALYSE DATA WITH EXCEL TABLES Formatting Excel Tables
t Select a Colour
From the Format Cells dialog, select the Fill tab then click More Colors to display the
colour palette. Enter the Red-Green-Blue (RGB) values of 252, 214 and 186 respectively;
then click OK.
u Format Borders
From the Format Cells dialog, select the Border tab.
From the Color drop-down list, select More Colors to display the colour palette. Enter
the RGB values of 148, 150 and 152 respectively and click OK.
Then apply a border to the top, middle and bottom of the rows and click OK.
48
ANALYSE DATA WITH EXCEL TABLES Formatting Excel Tables
Notice that as you progress with your formatting selections, a preview updates in the New
Table Style dialog.
From the New Table Style dialog click OK, when you have finished applying formatting.
To apply your new style, select your Table, from the Table Styles drop-down select your
style from the Custom category.
49
ANALYSE DATA WITH EXCEL TABLES Formatting Excel Tables
50
ANALYSE DATA WITH EXCEL TABLES Working with Excel Tables
51
ANALYSE DATA WITH EXCEL TABLES Working with Excel Tables
52
ANALYSE DATA WITH EXCEL TABLES Working with Excel Tables
Press CTRL+SPACE again to select the column including the Heading Row or Total Row.
Finally, press CTRL+SPACE a third time to select the entire worksheet column.
53
ANALYSE DATA WITH EXCEL TABLES Working with Excel Tables
Sometimes you may simply need to add more rows of data. Sometimes you will need new
columns for additional fields. This section covers several methods for adding new rows and
columns to your Table.
54
ANALYSE DATA WITH EXCEL TABLES Working with Excel Tables
55
ANALYSE DATA WITH EXCEL TABLES Working with Excel Tables
Quick Tip
You can only insert new columns to the left of the current column or at the end of your
Table. Because of this, if you try to right-click any column other than the last column of
your Table you will only see one Insert option when you right-click; that is, to insert a
column to the left of the current column.
Excel essentially ‘pushes’ all the other columns to the right, to insert your new column.
Simply select a cell in the first blank row after your Table and start typing. As soon as you
press ENTER, Excel expands your Table to include the new row.
56
ANALYSE DATA WITH EXCEL TABLES Working with Excel Tables
Quick Tip
You don’t need to type a value in the first column like the example above. You can enter
a value for any column in your new row. Press ENTER and your Table will expand to
include the new row.
57
ANALYSE DATA WITH EXCEL TABLES Working with Excel Tables
Quick Tip
You can only insert new rows above the current row or at the end of your Table. Because
of this, if you try to right-click any row other than the last row of your Table you will only
see one Insert option; that is to insert a row above the current row.
Excel essentially ‘pushes’ all the other rows down, to insert your new row.
58
ANALYSE DATA WITH EXCEL TABLES Working with Excel Tables
59
ANALYSE DATA WITH EXCEL TABLES Working with Excel Tables
Moving Columns
60
ANALYSE DATA WITH EXCEL TABLES Working with Excel Tables
Moving Rows
Follow these steps to move rows within your Table:
61
ANALYSE DATA WITH EXCEL TABLES Summarise with the Total Row
9 SUMMARISE WITH
THE TOTAL ROW
Excel allows you to summarise your Table with a Total Row. The Total Row lets you select
aggregations from a drop-down list after which Excel will enter the appropriate formula
for you.
62
ANALYSE DATA WITH EXCEL TABLES Summarise with the Total Row
o Select an Aggregation
Select your preferred aggregation from the list. Once you select an aggregation method,
Excel automatically inserts the required formula in the cell for you.
p More Functions
If the aggregation you want isn’t in the list, click ‘More Functions’ to display the Insert
Function dialog box.
63
ANALYSE DATA WITH EXCEL TABLES Summarise with the Total Row
n SUBTOTAL Function
The SUBTOTAL function is a special aggregation function. Unlike the SUM function,
SUBTOTAL ignores filtered rows. That is, if you filter your Table, SUBTOTAL will only
include rows which are visible:
o Structured References
The formula also uses a ‘structured reference’. That is, rather than using cells references, such
as ‘D3:D12’, the formula in this example uses the column heading ‘Billion Tons’. This is
similar to using a Named Range in your formula. One main difference is that the column
range updates automatically when you add or remove rows.
64
ANALYSE DATA WITH EXCEL TABLES Managing Data in an Excel Table
10 MANAGING DATA IN
AN EXCEL TABLE
Example Workbook
You can follow the examples in this section with this workbook:
In section 8.3, Adding Rows or Columns, we looked at adding a new row to the end of a
Table by manually entering your data.
If you already have existing data, provided it has the same structure, you can quickly copy-
and-paste it into your Table. ‘Same structure’ means your data has the same columns in the
exact same order as your Table.
65
ANALYSE DATA WITH EXCEL TABLES Managing Data in an Excel Table
Example Workbook
The following example workbook shows examples of different Table Styles:
Over time you may find that data in your Table is repeated or duplicated. Excel provides
a simple method to remove duplicate rows from your Table.
66
ANALYSE DATA WITH EXCEL TABLES Managing Data in an Excel Table
67
ANALYSE DATA WITH EXCEL TABLES Managing Data in an Excel Table
p Confirm Options
Excel will confirm your Table area and the columns Excel should include in determining
which rows are duplicated. Most of the time you don’t need to change any options. Simply
click OK.
q Confirm Results
Excel will delete the duplicate rows from your Table. Excel also confirms how many duplicate
rows were deleted and how many rows remain in your Table.
68
ANALYSE DATA WITH EXCEL TABLES Managing Data in an Excel Table
Note this does not delete the entire row (which could affect other data or formulas in your
worksheet. It only deletes rows within your Table.
Quick Tip
The Remove Duplicate feature can also be found on the Data ribbon tab. The Remove
Duplicate option in both the Data and Table Design tabs work exactly the same way.
69
ANALYSE DATA WITH EXCEL TABLES Sorting, Filtering & Slicing a Table
Example Workbook
You can follow the examples in this section with this workbook:
We will look at two approaches to sort your Table. For the first approach, ensure the
Filter Buttons are visible in your Table:
Let’s say you want to sort your Table by the ‘Units Sold’ showing the most ‘Units Sold’
to the least. That is, descending order from the largest to the smallest. To sort your list in
descending order, follow these steps:
70
ANALYSE DATA WITH EXCEL TABLES Sorting, Filtering & Slicing a Table
Note the icon next to the two sort options – you can also sort columns with text data.
Sorting Smallest to Largest will sort alphabetically from A to Z, while sorting Largest to
Smallest does the opposite. The same is true for sorting dates.
The second approach to quick sorting is via the Data ribbon tab:
71
ANALYSE DATA WITH EXCEL TABLES Sorting, Filtering & Slicing a Table
The sort options work the same as they do with the Filter Buttons. Simply select any cell
in the column you want to sort, and then click the appropriate sort button in the Data
ribbon tab, for the type of sort you require.
One common activity is to ‘colour code’ values in your data. You may do this to highlight
certain values using Conditional Formatting or the Fill Color tool.
You can then sort your Table by the colour in a given column like this:
72
ANALYSE DATA WITH EXCEL TABLES Sorting, Filtering & Slicing a Table
n Filter Button
Click the Filter Button of the column you want to sort using cells colours.
o Sort by Colour
Move your mouse over the Sort by Color option to display the submenu.
p Select Colour
From the submenu, select the colour you want to sort by
One thing you may have noticed with sorting so far, is that we have only sorted by one
column at-a-time. Sometimes you may want to sort your Table by multiple columns.
For example, you may want to sort the ‘Cars’ Table by ‘Manufacturer’ and ‘Model’ in
ascending order (A to Z) and then by ‘Units Sold’ in descending order (from largest to
smallest). Follow these steps to apply a custom sort order on multiple columns:
73
ANALYSE DATA WITH EXCEL TABLES Sorting, Filtering & Slicing a Table
n Custom Sort
Click any Filter Button in your Table. Then from the Sort by Color submenu select
Custom Sort. This will display the Sort dialog.
As we want to sort alphabetically in ascending order (A to Z), you don’t need to change
the Order option.
From here the process is the same as Step 2. Select the column to sort by (‘Model’ in our
example) and the sort Order.
Finally, click Add Level again to select a third column to sort by. Select ‘Units Sold’ and
then change to Order option to ‘Largest to Smallest’.
q Apply Sort
Once you have added as many columns you want to sort by, click OK to perform the sort.
Quick Tip
It’s often useful to return your Table back to its original sort order.
If you don’t have a column of values which could naturally be sorted (such as order number)
you may want to add a column specifically for this purpose. This example Table includes
a column called Sort Order with a sequential number that has been ‘AutoFilled’ down the
Table just for this purpose.
74
ANALYSE DATA WITH EXCEL TABLES Sorting, Filtering & Slicing a Table
Example Workbook
You can follow the examples in this section with this workbook:
Let’s say you only wanted to view the rows where ‘Ford’ is the manufacturer. Follow these
steps to apply a simple filter:
75
ANALYSE DATA WITH EXCEL TABLES Sorting, Filtering & Slicing a Table
76
ANALYSE DATA WITH EXCEL TABLES Sorting, Filtering & Slicing a Table
q Apply Filter
Click OK to apply the filter:
Quick Tip
Another approach when you have a very long list of values is to type the first few letters
of the value you want to filter from the list of possible values.
77
ANALYSE DATA WITH EXCEL TABLES Sorting, Filtering & Slicing a Table
Filter by colour works the same way as sort by colour. Follow these steps to filter your Table
by the colour of certain cells:
78
ANALYSE DATA WITH EXCEL TABLES Sorting, Filtering & Slicing a Table
After you have applied a filter you may want to remove the filter so you can see all the
rows again. There are two methods you can use to remove a Table filter.
79
ANALYSE DATA WITH EXCEL TABLES Sorting, Filtering & Slicing a Table
o Data Tab
Select the Data ribbon tab.
p Clear Filter
Click the Clear button. This is in the Sort & Filter group.
Example Workbook
You can follow the examples in this section with this workbook:
80
ANALYSE DATA WITH EXCEL TABLES Sorting, Filtering & Slicing a Table
Another method to filter Tables is with ‘slicers’. While slicers do not have the flexibility of
custom filtering they do offer the advantage of ‘one-click’ filtering.
Also, slicers are visual so it’s very easy to see how a Table is filtered compared to regular
filtering methods. Slicers also allow you to create interactive or dynamic dashboards although
the price you pay is ‘screen real-estate’ because they take up more space.
81
ANALYSE DATA WITH EXCEL TABLES Sorting, Filtering & Slicing a Table
o Insert Slicers
From the Table Design ribbon tab, select Insert Slicer.
Slicers for columns where there are many repeated values (such as ‘Region’) are typically more
useful slicers than columns where every value is unique (such as ‘Country’ or ‘Units Sold’).
q Apply Slicers
Click OK to add the selected slicers to your Table.
Quick Tip
Excel tends to ‘dump’ the Slicer boxes unceremoniously onto your worksheet. You can move
and resize them the same way as you would with a shape. Simply click on the border of
the slicer box and use the sizing handles around the perimeter to drag the slicer box to a
suitable size.
82
ANALYSE DATA WITH EXCEL TABLES Sorting, Filtering & Slicing a Table
There are several options on the slicer box worth knowing about. Let’s take a look at them:
n Slicer Caption
By default, Excel uses the column heading as the slicer caption. You can change this in the
slicer settings to something different, such as for a dashboard.
o Multi-Select Toggle
To select more than one filter item, you need to hold down the CONTROL key (COMMAND
on the Mac) just as you would when selecting multiple cells or multiple files in Windows
Explorer.
However, if you click the Multi-Select button, you can select multiple items simply by
clicking. Click once to select. Click again to deselect. This is useful when using slicers on
a touch screen device.
p Clear Filter
Clicking this button removes the filter (and selects all the available options) for this slicer.
83
ANALYSE DATA WITH EXCEL TABLES Sorting, Filtering & Slicing a Table
q Selected Values
The darker shaded values are currently selected. The unshaded values are not selected.
r Unavailable Values
The semi-shaded values are not available due to other filters currently being applied.
Just as you can format Tables, you can also format aspects of a Table’s slicers. This is useful
when designing dashboard reports. Here are just some of the slicer formatting options you
have available:
n Select Slicer
The first step is to select the slicer you want to format. Notice the round sizing handles
around the perimeter of the selected ‘Region’ slicer.
84
ANALYSE DATA WITH EXCEL TABLES Sorting, Filtering & Slicing a Table
o Slicer Caption
You can change the caption of the slicer. Excel uses the column heading for the slicer
caption, but you can change the Slicer Caption to something suitable for your dashboard.
If you don’t want the caption to appear at all, click the Slicer Settings button and remove
the check from the Display header option.
p Slicer Style
Like Tables, you can also apply predefined formatting styles to each slicer. Also like Tables,
you can create a new Slicer Style and customise it for more visual impact on a dashboard
report. The process of creating a custom Slicer Style is effectively the same as for Table
Styles. See Chapter 5, Creating Excel Tables for details.
85
ANALYSE DATA WITH EXCEL TABLES Analysing Tables with Formulas
12 ANALYSING TABLES
WITH FORMULAS
Example Workbook
You can follow the examples in this section with this workbook:
We have mentioned that Excel Table formulas use ‘structured references’. Let’s take a look
at what that means and how they work.
Before we do, let’s take a quick look at the structure of a regular formula for comparison:
n refers to the entire reference of this SUM function. Note that it includes a reference
to another worksheet contained in the current workbook. It’s also possible to include a
reference to another workbook.
86
ANALYSE DATA WITH EXCEL TABLES Analysing Tables with Formulas
Like the previous example, n refers to the entire reference of this SUM function. Note
there are no sheet names or cell references. Instead this reference uses the name of the Table
and the name of a column in that Table, making the formula more intuitive and easier to
read. This is a ‘structured reference’.
The structured reference starts with the name of the Table o. In chapter 0,
Naming an Excel Table, we discussed how useful it is to give all your Tables brief, yet
meaningful names. In this example, the structured reference is then followed by the name
of the column we want to sum p. Note also that the name of the column you want is
enclosed in square brackets (not parenthesis).
Essentially, the structured reference in this formula says, “sum from the Table called ‘Carbon’
everything in the column named ‘Billion Tons’”.
We also mentioned that you can reference specific ‘parts’ of a Table. Here’s an example
which does just that:
As before, the entire structured reference has several components n. Again, the reference
starts with the name of the Table o.
Now we have a difference; in the first example there was only one pair of square brackets.
In this example there are two. That’s because this formula is making two references. The first
is the special identifier for the Total Row p. Note that it starts with the hash or pound
sign. Then separated by a comma, we have a reference to the column q.
This formula is essentially saying, “from the Table called ‘Carbon’ sum the Total Row value
for the column called ‘Billions Tons’.
Even better, you don’t need to remember Table names, special sections or column names can
be used to quickly create formulas for Tables. Excel’s ‘Intellisense’ will display the choices
you have from a list like this:
87
ANALYSE DATA WITH EXCEL TABLES Analysing Tables with Formulas
When you start typing a formula in a cell, Excel displays an ‘Intellisense’ list which shows
the choices you have available. As you type, the list is filtered to show only applicable
choices. This includes Named Ranges and the names of Table.
Once you enter the opening square bracket ([) after the Table name, the list above will
appear with the following options:
n This Row
This Row is a special reference to values on the current row when you create formulas in
the Table itself.
o Column Headings
The list includes each of your Table’s column headings. Use your up and down arrow keys
to select a column name and then tab to select it.
p Table Sections
The values which start with the hash or pound symbol are sections of your Table you can
reference in your formula. We’ll look at technique using #Header later in Section 12.7,
Dynamically Reference Columns with VLOOKUP.
88
ANALYSE DATA WITH EXCEL TABLES Analysing Tables with Formulas
n File Options
From the File menu, select Options.
o Formula Options
From the Excel Options dialog select the Formulas options from the list on the left.
89
ANALYSE DATA WITH EXCEL TABLES Analysing Tables with Formulas
q Apply Change
Click OK to apply the change.
Note that turning off structured references will not convert existing formulas which contain
structured references. Instead, any new formulas you write which reference a Table will use
cell references instead of structured references.
Here’s a ‘before’ and ‘after’ comparison of the same formula with and without structured
references:
90
ANALYSE DATA WITH EXCEL TABLES Analysing Tables with Formulas
Example Workbook
You can follow the examples in this section with this workbook:
91
ANALYSE DATA WITH EXCEL TABLES Analysing Tables with Formulas
n Select Cell
Select a blank cell in the column you want to enter your formula. Note you do not have
to select the cell in the first row (this is intentional to demonstrate how Tables work).
o Select Numerator
On your keyboard enter the ‘=’ sign to start a formula and then press the left arrow twice.
Notice how Excel enters the name of the column rather than a cell reference.
p Select Denominator
Enter the ‘/’ division symbol and then press the left arrow once.
q Enter Formula
Pres ENTER. Notice that your formula is copied down the entire column automatically.
One aspect to notice about the formula is that the name of each column is prefixed with
the ‘@’ symbol. In structured references, this tells Excel to use the value on the current row.
That is, on any given row, the formula above says: “Take the ‘Population’ value on the
current row and divide it by the ‘Area (km2)’ value on the current row”.
In contrast, the following formula calculates the percentage each row comprises of the total:
92
ANALYSE DATA WITH EXCEL TABLES Analysing Tables with Formulas
Figure 96: Formulas which combine current row with total row
Notice that the numerator (the first ‘Billion Tons’) is prefixed with the ‘@’ symbol to reference
the current row. In contrast, the denominator (the second ‘Billion Tons’) is prefixed with
#Totals which tells Excel to use the Billion Tons value in the Total Row.
Example Workbook
You can follow the examples in this section with this workbook:
We’ll start by creating a unique list of ‘Regions’ based on the ‘Countries’ Table.
93
ANALYSE DATA WITH EXCEL TABLES Analysing Tables with Formulas
94
ANALYSE DATA WITH EXCEL TABLES Analysing Tables with Formulas
95
ANALYSE DATA WITH EXCEL TABLES Analysing Tables with Formulas
Example Workbook
You can follow the examples in this section with this workbook:
96
ANALYSE DATA WITH EXCEL TABLES Analysing Tables with Formulas
When you use a Table name as the lookup range (that is, the ‘Table array’ parameter) the
Table can be in a different worksheet. Tables help keep the formula simpler as you do not
need to include the sheet name.
97
ANALYSE DATA WITH EXCEL TABLES Analysing Tables with Formulas
Example Workbook
You can follow the examples in this section with this workbook:
o VLOOKUP Formulas
VLOOKUP formulas to retrieve values from your Table based on the Country selected
from the drop-down list.
98
ANALYSE DATA WITH EXCEL TABLES Analysing Tables with Formulas
In a worksheet, the following formula will return the full list of ‘Country’ values from the
‘Countries’ Table:
=Countries([Country])
However, as the ‘Source’ for a Data Validation rule it won’t work. But there is a work-around.
Wrapping the Table and column reference as text inside the indirect function will allow
you to create a dynamic Data Validation drop-down list using a Table column, like this:
=INDIRECT(“Countries([Country])”)
Now that you have a list of countries in a drop-down list, let’s enter a VLOOKUP formula
which references the Table.
You will need to change the Column Index Number parameter for each VLOOKUP manually.
When you only have a handful of VLOOKUP formulas, this is a simple task. However, if
you have many vlookup formulas, this can be time consuming.
Let’s look at a smarter way to dynamically reference columns headings in your Table.
Example Workbook
You can follow the examples in this section with this workbook:
If you have used a VLOOKUP function to retrieve values from a list or Table, you may
have experienced problems when columns were added or removed from the list, or perhaps
columns were rearranged.
Adding, moving or removing columns affects the position of each column so your VLOOKUP
formulas may return values from the incorrect column.
101
ANALYSE DATA WITH EXCEL TABLES Analysing Tables with Formulas
Here’s an example
This VLOOKUP function looks up the value of the ‘Country Code’ in cell A16, from the
Table called ‘CarsSold’ and retrieves the value in column number 5. Column 5 contains
the ‘Units Sold’.
However, if you rearrange the Table columns using the method discussed in section ‘8.5
Moving Columns or Rows’, your VLOOKUP formula continues to retrieve the value in
column 5 even though the ‘Units Sold’ may now be in a different column. As can be seen
in the example below, this now returns the incorrect result.
Figure 99: Table VLOOKUP with static column reference causing an error
This technique will allow your VLOOKUP function to still work correctly even if the
columns change order.
102
ANALYSE DATA WITH EXCEL TABLES Analysing Tables with Formulas
Rather than ‘hard-code’ the column position in your VLOOKUP formula, another approach
is to use Excel’s MATCH function to dynamically ‘find’ the position of the column you want.
Let’s start by writing the MATCH function in a separate cell first. This allows you to test
the function and confirm it works as expected.
In this example, the MATCH function finds the position of the column in the Headers
section of the ‘CarsSold’ Table which contains ‘Units Sold’.
Once you have confirmed the MATCH function returns the correct value, you can
incorporate it into your VLOOKUP function by replacing the hard-coded column value
with the match function:
Now, if columns are inserted, removed or moved in your Table, your VLOOKUP function
will continue to return the value from the correct column.
103
ANALYSE DATA WITH EXCEL TABLES Working with Multiple Tables
13 WORKING WITH
MULTIPLE TABLES
If you use VLOOKUP to combine data from two or more Tables, you are probably
adding unnecessary duplication into your data. Also, if your spreadsheet is large, too many
VLOOKUP formulas can affect the performance of your spreadsheet given the VLOOKUP
function is relatively slow.
In contrast, ‘connecting’ Excel Tables lets you consolidate values from several Tables without
having to use any ‘lookup’ functions such as VLOOKUP, INDEX or MATCH (or even the
new VLOOKUP ‘killer’ XLOOKUP!).
There are several criteria your Tables must meet before you can connect them:
1. Both Tables should contain at least one column with ‘common values’. The
column headings, however, do not need to be the same.
2. In one of the Tables, the column with common values should not have any
duplicates. These values must be unique. This is typically your ‘lookup’ Table.
It’s also convenient to name each Table something meaningful rather than just ‘Table1’
and ‘Table2’.
Example Workbook
You can follow the examples in this section with this workbook:
This example workbook contains 3 Tables: Sales, Employees and States. There’s a snapshot
of each below.
104
ANALYSE DATA WITH EXCEL TABLES Working with Multiple Tables
The ‘Sales’ Table has an ‘Employee’ and ‘State’ columns. Any given ‘Employee’ or ‘State’
appears multiple times in the ‘Sales’ Table.
The ‘Employees’ Table has an ‘Employee ID’ column. Each employee appear only once.
Even though the column headings differ, the employee ID values match between the ‘Sales’
and ‘Employees’ Tables.
The same is true for the ‘States’ Table. Each state is only listed once, but the values match
the ‘State’ in the ‘Sales’ Table.
This is done via the Relationships button on the Data ribbon tab which has the following
options:
105
ANALYSE DATA WITH EXCEL TABLES Working with Multiple Tables
Table
The first Table where the values in the common column are used more than once. This is
usually the larger Table with more detail.
Column (Foreign)
The name of the column you want to connect with. This is the column which contains
values common to both of the two Tables.
Related Table
The second Table where the values in the common column are unique.
This column often has the same name as that in the first Table, but this isn’t mandatory.
For example, the first Table may have ‘Emp ID’ while the second has ‘Employee Code’.
The important thing is that both columns contain the same values and in one Table they
are unique while in the other Table they are repeated.
106
ANALYSE DATA WITH EXCEL TABLES Working with Multiple Tables
107
ANALYSE DATA WITH EXCEL TABLES Working with Multiple Tables
108
ANALYSE DATA WITH EXCEL TABLES Working with Multiple Tables
The PivotTable Fields pane will allow you to select fields from all the Tables which are
connected like the example below:
109
ANALYSE DATA WITH EXCEL TABLES Working with Multiple Tables
You can create as many connections, or relationships, between Tables as you like, provided
there is a common field between each two Tables you want to connect.
This allows you to avoid either combining the data from each Table together or complex
VLOOKUP formulas to bring the data together.
To learn more about the power of PivotTables, take a look at our title ‘Analyse Data with
PivotTables’.
If you are already familiar with PivotTables, remember that Excel Tables are the perfect
Excel-based data source for PivotTables. If you intend to create a PivotTable from an Excel
range, convert it to a Table first.
110
ANALYSE DATA WITH EXCEL TABLES Advanced Techniques
14 ADVANCED TECHNIQUES
Example Workbook
You can follow the examples in this section with this workbook:
One approach is to enter values ‘1’ and ‘2’ in the first two rows of an ID column and then
use AutoFill to copy the numbers down the Table.
One problem with this approach is the sequence will be broken when you insert or delete
rows from your Table.
A more consistent way to add a sequential number in your Table is with a formula. The
row() function is a reference function which tells you the row number of the current cell
or a specific cell.
111
ANALYSE DATA WITH EXCEL TABLES Advanced Techniques
Using the ROW function, even if you delete rows from your Table, or add new rows in the
middle of your Table, will always result in a sequential number down your Table.
Where TableName is the name of your Table and ColumnName is the name of a column
in your Table.
Note, the Headers reference and column name are both enclosed in a separate set of square
brackets separated by a comma. If you miss this, Excel may warn you there are too many
arguments for this formula.
For example, the Table is named ‘Carbon’. Imagine you want a sequential number in the
ID Column. The formula would be:
Here’s an example:
112
ANALYSE DATA WITH EXCEL TABLES Advanced Techniques
Tips
If you want the sequential number to start from something other than 1, you can add a
‘seed value’ to the formula. For example, if you want your sequential number to start from
1000, add 999 to your formula:
Your sequential number can also have text in it by adding a text prefix or suffix using the
ampersand (&) symbol or CONCATENATE function to concatenate any text you require.
Example Workbook
You can follow the examples in this section with this workbook:
You also can add a running total, also known as a cumulative total, to your Table. This is
where the value for each row, shows the total for a column up to that row.
113
ANALYSE DATA WITH EXCEL TABLES Advanced Techniques
=SUM(TableName[[#Headers],[ColumnName]]:[@[ColumnName]])
Here’s an example:
If you enter more rows of data, the running total will be updated automatically.
Alternatively, if you want a running total based on the value of a specific column, you can
use the SUMIF function instead.
=SUMIF(Carbon2[[#Headers],[Region]]:[@Region],[@Region],Carbon2[[#Headers],[Billi
on Tons]]:[@[Billion Tons]])
114
ANALYSE DATA WITH EXCEL TABLES Advanced Techniques
Filtering the list, you can quickly confirm with the Status Bar totals that the conditional
running total is correct:
Example Workbook
You can follow the examples in this section with this workbook:
Sometimes you need to ensure that values in a specific column are not repeated. Values
such as employee IDs and products codes often have to be unique.
115
ANALYSE DATA WITH EXCEL TABLES Advanced Techniques
This technique is based on setting a Data Validation rule on a column in your Table using a
‘Named Range’. Because the Named Range is within your Table, it will expand (or contract)
automatically as you add or remove rows from your Table.
Let’s say you wanted to ensure the ‘Country Code’ in this Table was unique:
Start by naming the column (excluding the Column Heading) you want to prevent duplicate
values in. Here we have named the Country Code column ‘CountryCode’. The Table itself
is named ‘CarsSold’:
Next, select the CountryCode named range, then from the Data tab select Data Validation.
116
ANALYSE DATA WITH EXCEL TABLES Advanced Techniques
From the Allow drop-down list select Custom. Then, in the Formula box enter the following
formula:
=COUNTIF(CountryCode, A2) = 1
Data Validation rules require a formula which returns True or False. The Data Validation
rule will be triggered when your formula returns False.
In this example, the formula counts how many times the ‘Country Code’ in cell A2 appears
in the Named Range ‘CountryCode’. If the count equals 1, the formula returns True and
the Data Validation rule is not breached. If it appears more than once, the Data Validation
rule will be evoked:
117
ANALYSE DATA WITH EXCEL TABLES Advanced Techniques
As this name references an area in your Table, it will be dynamic. That is, it will expand
(or contract) automatically as you add or remove rows.
Quick Tip
When entering the validation formula, rather than typing the name of the range, on your
keyboard press f3. This will display the Paste Name dialog from which you can select the
Named Range rather than typing it.
Figure 116: Using the Paste Name box to enter a Table name
118
ANALYSE DATA WITH EXCEL TABLES Keyboard Shortcuts
15 KEYBOARD SHORTCUTS
The table below lists keyboard shortcuts specifically for working with Excel Tables, including
both Windows and Mac versions.
119