0% found this document useful (0 votes)
23 views

Analyse Data With Excel Tables

Uploaded by

kaveh.rezaeii90
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Analyse Data With Excel Tables

Uploaded by

kaveh.rezaeii90
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 119

Marcus Syben

Analyse Data with Excel


Tables
Master Excel Tables to Manage
and Analyse your Data
MARCUS SYBEN

ANALYSE DATA WITH


EXCEL TABLES
MASTER EXCEL TABLES
TO MANAGE AND
ANALYSE YOUR DATA

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

2 Introducing Excel Tables 13


2.1 What is an Excel Table 13
2.2 How Tables Differ from Normal Lists 13

3 Top 10 Benefits of Excel Tables 15


3.1 Tables are Easy to Create 15
3.2 Tables are Easy to Select and Refer to 16
3.3 Tables are Dynamic 16
3.4 Tables Have Slicers 18
3.5 Tables Have Calculated Columns 19
3.6 Tables Have Structured References 20
3.7 Tables Have a Total Row 20
3.8 Table Column Names are Always Visible 21
3.9 Tables Have Preformatted Styles 22
3.10 You Can Combine Data from Multiple Tables 22

4 Anatomy of an Excel Table 23


4.1 Different Parts of an Excel Table 23
4.2 Table Constraints 27

5 Creating Excel Tables 29


5.1 Insert Ribbon Tab 29
5.2 Format as Table 31
5.3 Quick Analysis Menu 34
5.4 Keyboard Shortcut 36

6 Naming an Excel Table 38


6.1 Why Name Your Tables 38
6.2 How to Name Your Table 38
6.3 Rules for Table Names 40

4
ANALYSE DATA WITH EXCEL TABLES Contents

7 Formatting Excel Tables 42


7.1 Table Format Styles 42
7.2 Removing the Table Format 43
7.3 Table Style Options 44
7.4 Creating a Custom Table Format Style 44
7.5 Modifying a Custom Table Style Format 49

8 Working with Excel Tables 51


8.1 Navigating around an Excel Table 51
8.2 Selecting Areas of an Excel Table 51
8.3 Adding Rows or Columns 54
8.4 Deleting Rows or Columns 58
8.5 Moving Columns or Rows 60

9 Summarise with the Total Row 62


9.1 Displaying the Total Row in an Excel Table 62
9.2 How to Change the Summary Formula 63
9.3 Filtering and the Subtotal Function 64

10 Managing Data in an Excel Table 65


10.1 Copying & Pasting Data to a Table 65
10.2 How to Remove Duplicates from a Table 66

11 Sorting, Filtering & Slicing a Table 70


11.1 How to Sort an Excel Table 70
11.2 How to Filter an Excel Table 75
11.3 Using Slicers with an Excel Table 80

12 Analysing Tables with Formulas 86


12.1 Structured References in Excel Tables 86
12.2 How to Turn Off Structured Referencing 89
12.3 Creating Formulas inside an Excel Table 90
12.4 Using COUNTIF Formulas with Tables 93
12.5 Using SUMIF Formulas with Tables 96
12.6 Using vlookup formulas on an Excel Table 97
12.7 Dynamically Reference Columns with vlookup 101

13 Working with Multiple Tables 104


13.1 Connecting Tables 104
13.2 Creating Relationships between two Tables 105
13.3 Creating a Single Report from Multiple Tables 108

5
ANALYSE DATA WITH EXCEL TABLES Contents

14 Advanced Techniques 111


14.1 How to Add an ID Column of Sequential Numbers 111
14.2 How to Add a Running Total to a Table 113
14.3 How to Prevent Duplicate Values in a Column 115

15 Keyboard Shortcuts 119


15.1 Keyboard Shortcuts for working with Tables 119

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

Figure 39: Remove the Table Style formatting 43


Figure 40: Table Style Options 44
Figure 41: Create a Custom Table Style 45
Figure 42: Format elements of a Table Style 46
Figure 43: Select elements to format for a new Table Style 47
Figure 44: Edit custom Table Style colours 47
Figure 45: Edit custom Table Style borders 48
Figure 46: New Table Style preview 49
Figure 47: Completed custom Table Style 49
Figure 48: Modifying a custom Table Style format 50
Figure 49: Selecting Tables with the Name Box 51
Figure 50: Selecting a Table row with your mouse 51
Figure 51: Selecting a Table column with your mouse 52
Figure 52: Selecting a Table row with your keyboard 52
Figure 53: Selecting an entire row with your keyboard 53
Figure 54: Selecting a Table column with your keyboard 53
Figure 55: Selecting an entire column with your keyboard 54
Figure 56: Adding a column to the right of your Table 55
Figure 58: Adding a row at the end of your Table 57
Figure 59: Adding a row in the middle of your Table 58
Figure 60: Deleting Columns or Rows via the Shortcut Menu 59
Figure 61: Deleting Columns using Keyboard Shortcuts 59
Figure 62: Deleting Rows using Keyboard Shortcuts 60
Figure 63: Moving columns in your Table 61
Figure 64: Moving rows in your Table 61
Figure 65: Displaying the Total Row 62
Figure 66: Changing th Total Row Summary Formula 63
Figure 67: The Total Row SUBTOTAL function 64
Figure 68: The SUBTOTAL function only includes visible rows 64
Figure 69: Copying & pasting data to a Table 66
Figure 70: Removing duplicates from a Table 68
Figure 71: Table Filter Buttons 70
Figure 72: Sorting a Table via the Filter Buttons 71
Figure 73: Sorting a Table via the Data ribbon tab 72
Figure 74: Sorting a Table by cell colour 72
Figure 75: Performing a custom sort 73
Figure 76: Table Filter Buttons 75
Figure 77: Filtering a Table via the Filter Buttons 76
Figure 78: A filtered Table 77
Figure 79: Filtering a column with many values 77

8
ANALYSE DATA WITH EXCEL TABLES Contents

Figure 80: Filtering a Table by cell colour 78


Figure 81: Removing a Table filter 79
Figure 82: Clearing a Table filter 80
Figure 83: An example of Table slicers 81
Figure 84: Filtering a Table with Slicers 81
Figure 85: Moving & resizing Table Slicers 82
Figure 86: Anatomy of a Table Slicer 83
Figure 87: Formatting Table Slicers 84
Figure 88: Standard formula structure 86
Figure 89: Table formula with structured reference 86
Figure 90: Reference specific Table elements in a formula 87
Figure 91: Table formula Intellisense 88
Figure 92: Turning off structured references 89
Figure 93: Comparing formulas with & without structured references 90
Figure 94: Creating Formulas inside an Excel Table 91
Figure 95: Current row formula notation 92
Figure 96: Formulas which combine current row with total row 93
Figure 97: Using VLOOKUP with Tables example 98
Figure 98: Table VLOOKUP with static column reference 102
Figure 99: Table VLOOKUP with static column reference causing an error 102
Figure 100: Using the MATCH function to create a dynamic reference 103
Figure 101: Table VLOOKUP with dynamic column reference 103
Figure 102: Connecting Tables with Relationships 105
Figure 103: Creating a Relationship between two Tables 105
Figure 104: A PivotTable report based on multiple Tables 109
Figure 105: Adding an ID column with AutoFill 111
Figure 106: Using the ROW function for ID columns 112
Figure 107: Adding a dynamic ID column with the ROW function 113
Figure 108: Adding extra characters to an ID column 113
Figure 109: Adding a ‘running total’ to a Table 114
Figure 110: The structure of the running total formula 115
Figure 111: Confirming your running total is correct 115
Figure 112: Preventing duplicate values in a Table column 116
Figure 113: Naming the Table column to prevent duplicates in 116
Figure 114: Entering the Data Validation formula to prevent duplicates 117
Figure 115: Example error message to prevent duplicates in a column 117
Figure 116: Using the Paste Name box to enter a Table name 118

9
ANALYSE DATA WITH EXCEL TABLES About the author

ABOUT THE AUTHOR


Marcus Syben has been an Excel Consultant & VBA Developer for over 20 years working
with clients with 2 staff through to 200,000.

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.”

Put simply: learning to analyse data is critical to your career.

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

1.1 WHO THIS BOOK IS FOR


This book is for people who want more control over the data they work with in Excel.

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.

1.2 WHAT THIS BOOK INCLUDES


This book is divided into chapters by topic. If you have created an Excel Table before, you
may want to skip ahead to some of the more advanced topics (but then you would miss
out on the Top 10 Benefits of Excel Tables in Chapter 3 and not discover the 4 different
ways of Creating Excel Tables in Chapter 5).

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.

1.3 HOW TO DOWNLOAD THE SAMPLE WORKBOOKS


This book also comes with example workbooks. While you can read this book without the
example workbooks, they will save you time and give you sample data to practice with.
You can also copy the formulas and techniques for your own work.

You can download the zip file here


https://myexcelgenius.com/bookboon/

12
ANALYSE DATA WITH EXCEL TABLES Introducing Excel Tables

2 INTRODUCING EXCEL TABLES

2.1 WHAT IS AN EXCEL TABLE


One of the most common uses of Microsoft Excel is to create, manage and analyse lists of
data. Often these lists become too unmanageable to maintain and analyse effectively. For
example, there may be hundreds (or thousands) of VLOOKUP formulas trying to collate
data from various tables.

This is where Excel Tables come in.

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.

2.2 HOW TABLES DIFFER FROM NORMAL LISTS


There are several differences between a designated Table range and a regular list of data;
some subtle, some less so.

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.

Sorting & Filtering


Sorting and filtering work the same with regular lists and Excel Tables. However with
unkempt lists, Excel occasionally gets the list boundary wrong and applies a filter to the
incorrect columns.

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.

3.1 TABLES ARE EASY TO CREATE


Tables are a simple way to create a structured data layout which is easy to manipulate,
manage and analyse without having to create a dynamic named range.

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.

NITO HOLDER DEG


OPPDATERT:
> Teknisk ukeblad
> Medlemsavisen NITO Refleks
> Bioingeniøren til deg som studerer
bioingeniørfag
> Nyhetsbrev og gratis temamøter gjennom
våre fagnettverk

Les mer på www.nito.no/medlem

15
ANALYSE DATA WITH EXCEL TABLES Top 10 Benefits of Excel Tables

3.2 TABLES ARE EASY TO SELECT AND REFER TO


Excel Tables are always named. You can assign almost any name you like to a Table. This
makes them very easy to select and reference. This is far more intuitive than having a series
of lists in multiple tabs and having to remember cells’ addresses.

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:

Figure 1: The Go To Dialog

Alternatively, you can quickly jump to a Table via the Named Range list:

Figure 2: Named Range list

3.3 TABLES ARE DYNAMIC


The size of a Table expands as you add more rows or columns of data. You don’t even need
to rename the area of a Table. Excel updates a Table area automatically.

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

Figure 3: Cell reference using a regular list

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.

Figure 4: Cell reference using an Excel Table

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:

Figure 5: Chart using 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:

Figure 7: Chart using 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:

Figure 8: Chart using Excel Table includes new rows

3.4 TABLES HAVE SLICERS


Slicers allow you to quickly ‘slice and dice’ your Table by applying filters with one click.

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

Figure 9: Tables have slicers

Slicers are a handy tool to build reports and management dashboards.

3.5 TABLES HAVE CALCULATED COLUMNS


With the ‘Calculated Columns’ feature, Excel will apply the same formula to the entire
column of your Table. Excel will also automatically copy your Table’s formulas down each
time a new row is added.

Figure 10: Tables have calculated columns

19
ANALYSE DATA WITH EXCEL TABLES Top 10 Benefits of Excel Tables

3.6 TABLES HAVE STRUCTURED REFERENCES


Rather than cell references such as A5:J47, Excel Tables have structured references that
you can refer to by name. That is, Excel uses the Table’s column names in the formulas
rather than cell references. This can make formulas far more intuitive and makes debugging
formulas easier as well.

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.

3.7 TABLES HAVE A TOTAL ROW


The ‘Total Row’ provides a quick way to display common aggregations in your Table without
having to manually enter any formulas yourself.

Figure 11: Tables have a Total Row

Note also that Excel uses the SUBTOTAL function.

20
ANALYSE DATA WITH EXCEL TABLES Top 10 Benefits of Excel Tables

Figure 12: Table Total Row uses the SUBTOTAL function

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.

3.8 TABLE COLUMN NAMES ARE ALWAYS VISIBLE


Even if you don’t lock in row headers, the Column Names in a Table are always visible
as you scroll down a spreadsheet. Excel replaces the alphabetical column’s labels with the
names of your Table’s columns:

Figure 13: Table column headings are always visible

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

3.9 TABLES HAVE PREFORMATTED STYLES


There are over 50 predefined styles you can use to quickly format your Table. You can also
create your own Table styles to follow your company’s colour scheme.

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.

Figure 15: Table preformatted styles

3.10 YOU CAN COMBINE DATA FROM MULTIPLE TABLES


Often you may need to create a report that combines data from several lists in your workbook.

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

4 ANATOMY OF AN EXCEL TABLE

4.1 DIFFERENT PARTS OF AN EXCEL TABLE


An Excel Table is comprised of several parts, many of which can be referenced in your
formulas.

Let’s look at each part of the Table in more detail:

Figure 16: Different parts of a 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

Figure 17: The Create Table dialog

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.

Figure 18: Total Row drop-down list of functions

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.

SØKER DU JOBB ELLER


NYE UTFORDRINGER?
Som medlem i NITO får du:
> CV og søknadshjelp
> Råd om arbeidskontrakt
> Lønnsstatistikk
> Karriereveiledning
> Rabatt på alle våre fagkurs

Les mer på www.nito.no/medlem

25
ANALYSE DATA WITH EXCEL TABLES Anatomy of an Excel Table

Figure 19: Toggle Filter Arrows on Tables

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’:

Figure 20: Table sizing 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

4.2 TABLE CONSTRAINTS


Excel Tables provide a structured, yet flexible, way to manage and analyse your data. However,
there are some constraints on how you can create and use Tables. Here’s some things you
may want to consider:

Single Heading Row


Each Table may only have a single Heading Row. That is, your column headings may not
go over multiple rows. However, there is a work-around.

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.

Figure 21: Enter heading text over multiple lines

Single Total Row


Each Table may only have a single Total Row. This constraint doesn’t stop you from creating
a separate summary over multiple rows below or away from your Table.

Unique Column Names


Excel Tables use structured references which are also used in formulas. Just as each cell
reference in a worksheet is unique, each column heading in a Table must be unique.

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

Figure 22: Table must have unique column names

Self-Contained
Each Table must be self-contained. That is, any given Table cannot overlap with another
Table.

Have a Unique Name


Excel automatically gives your Table a name when you create it starting with ‘Table1’. You
may rename your Table to something meaningful, however, each Table in a given workbook
must have unique name.

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

5 CREATING EXCEL TABLES


In this chapter you will learn four different ways to create an Excel Table. Once you are
familiar with each method, you can use whichever method best fits your requirements. For
example, some people prefer keyboard shortcuts when they are available.

Example Workbook
You can follow the examples in this section with this workbook:

\05 Creating Excel Tables\Creating Excel Tables.xlsx

5.1 INSERT RIBBON TAB


The first method to insert a Table is via the Table option on the Insert ribbon tab.

n Display your list


First open Excel and have your tabular list of data displayed in front of you. Then select
any cell in your data range. Here we have cell C4 selected in our list.

Figure 23: A plain list to convert to a Table

29
ANALYSE DATA WITH EXCEL TABLES Creating Excel Tables

o Display the Insert tab


From the Excel ribbon, select the Insert tab, and then click the Table button.

p Confirm the Table area


Excel will guess the area of your Table. If Excel has guessed correctly, simply click OK.

Figure 24: Confirm the area of your Table

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

Figure 25: New Table with the default Table Style

5.2 FORMAT AS TABLE


The second method to format your list as a Table uses the Format as Table option on the
Insert ribbon tab.

n Display your list


First open Excel and have your tabular list of data displayed in front of you. Then select
any cell in your data range. Here we have cell C4 selected.

Figure 26: Formatting your Table

31
ANALYSE DATA WITH EXCEL TABLES Creating Excel Tables

o Display the Home tab


From the Excel ribbon, select the Home tab, and then click the Format as Table button.

Figure 27: Format As Table from Home ribbon tab

p Select a Table Style


When you click the Format as Table button, Excel will present you with a list of Table
Styles. Select a style from the list (note the image below has been edited for size).

Figure 28: Format As Table Styles

32
ANALYSE DATA WITH EXCEL TABLES Creating Excel Tables

q Confirm the Table area


Excel will guess the area of your Table. If Excel has guessed correctly, click OK.

Figure 29: Format As Table, confirm the Table area

Once you click OK, Excel designates the area as a ‘Table’ and formats it with the Table
Style you selected earlier.

Figure 30: Format As Table with selected Table Style

33
ANALYSE DATA WITH EXCEL TABLES Creating Excel Tables

5.3 QUICK ANALYSIS MENU


The third method is useful if you prefer using short-cut menus.

n Display your list


First open Excel and have your tabular list of data displayed in front of you. Then select
any cell in your data range. Here we have cell C4 selected.

Figure 31: Quick Analysis Menu - Display your list

o Right-Click Your List


Right-click a cell in your list to display the short-cut menu and select Quick Analysis.

34
ANALYSE DATA WITH EXCEL TABLES Creating Excel Tables

Figure 32: Quick Analysis Menu - display shortcut menu

p Select a Table Style


This will display the Quick Analysis menu. From the Quick Analysis menu, select the
Tables submenu and then click Table.

35
ANALYSE DATA WITH EXCEL TABLES Creating Excel Tables

Figure 33: Quick Analysis Menu - select Table Style

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.

5.4 KEYBOARD SHORTCUT


The fourth and final method is perhaps the fastest technique for creating a Table. Three
keystrokes and you’re done.

n Display your list


First open Excel and have your tabular list of data displayed in front of you. Then select
any cell in your data range. Here we have cell C4 selected.

36
ANALYSE DATA WITH EXCEL TABLES Creating Excel Tables

Figure 34: Keyboard shortcut - display your list

o Press Keyboard Shortcut


On your keyboard, press the keyboard shortcut of CTRL+T (or ^+T on a Mac). This will
display the Create Table dialog. Now simply press ENTER on your keyboard.

That’s it. Three quick keystrokes: CTRL+T then ENTER.

Figure 35: Keyboard shortcut - confirm Table range

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

6 NAMING AN EXCEL TABLE

6.1 WHY NAME YOUR TABLES


Every Table you create is automatically given a name by Excel. The default Table name
is ‘Table1’. Each Table you create after the first is appended with a sequential number:
‘Table2’, ‘Table3’ and so on.

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.

Figure 36: Table Names - standard vs custom

6.2 HOW TO NAME YOUR TABLE


A great time to name your Table is as soon as you create it. However, you can assign a
name to, or rename, your Tables at any time.

To name (or rename) your Table, follow these steps:

38
ANALYSE DATA WITH EXCEL TABLES Naming an Excel Table

Figure 37: How to name your Table

n Select Your Table


The first step is to select your Table or any cell in your Table.

o Select the Table Design tab


When you select a Table, Excel displays the Table Design tab on the ribbon, but it doesn’t
always activate it. So, if necessary, select the Table Design tab.

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.

p Select the Table Name box


Finally, select the Table Name box, type the name of your Table and then press ENTER.

39
ANALYSE DATA WITH EXCEL TABLES Naming an Excel Table

6.3 RULES FOR TABLE NAMES


While you have a lot of flexibility in naming Excel Tables, there are a few rules to bear in
mind:

Start with a Letter or Underscore


Your Table name must start with a letter of the alphabet or an underscore character (_).
You can then use any combination of letters, numbers, periods and underscores for the
rest of the name.

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’.

Not a Cell Reference


Names can’t be the same as a cell reference. For example, ‘A1’, ‘Z$100’ and ‘R1C1’ are not
valid Table names.

40
ANALYSE DATA WITH EXCEL TABLES Naming an Excel Table

Not Too Long


Excel provides a very generous 255 characters to name your 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

7 FORMATTING EXCEL TABLES

7.1 TABLE FORMAT STYLES


Excel manages the formatting of a Table with the use of ‘styles’. A style is simply a named
set of predefined formatting attributes including borders and shading.

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:

\07 Formatting Excel Tables\Table Format Styles.xlsx

To Change the Table Style


To change the Table Style, follow these steps:

Figure 38: Change the Table Style

42
ANALYSE DATA WITH EXCEL TABLES Formatting Excel Tables

n Select Your Table


The first step is to select your Table or any cell in your Table.

o Select the Table Design tab


If necessary, select the Table Design tab.

p Select the Table Name box


Click the down-arrow to the right of the Table Styles list.

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.

7.2 REMOVING THE TABLE FORMAT


It is also possible to remove all Table Style formatting while keeping your list as a recognised
‘Table’.

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.

Figure 39: Remove the Table Style formatting

43
ANALYSE DATA WITH EXCEL TABLES Formatting Excel Tables

7.3 TABLE STYLE OPTIONS


Before we look at customising Table Styles, it’s worth knowing that Excel also provides
some options to quickly modify parts of the applied style.

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.

Figure 40: Table Style Options

7.4 CREATING A CUSTOM TABLE FORMAT STYLE


Excel allows you to create and customise your own Table Styles. For instance, you can
incorporate your own business or corporate colour scheme into a custom Table Style.

For this example, we’ll assume you want to apply the below colour scheme to your table:

Table Section Colour Colour Definition

Header Row Dark Grey RGB(74, 75, 79)

First Row Stripe Shading Pale Orange RGB(252, 214, 186)

First Row Stripe Border Grey RGB(148, 150, 152)

44
ANALYSE DATA WITH EXCEL TABLES Formatting Excel Tables

Create a Custom Table Style


Follow these steps to create a custom Table Style:

Figure 41: Create a Custom Table Style

n Create & Name Your Style


From the Table Styles drop-down list select New Table Style (right at the end of the list).
The New Table Style dialog will display. Click in the Name box and give your style a short
but meaningful name.

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.

p Select Element to Format


Next, select the Table Element to format and click the Format button. In this example,
we will first format the ‘Header Row’.

45
ANALYSE DATA WITH EXCEL TABLES Formatting Excel Tables

Figure 42: Format elements of a Table Style

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

Figure 43: Select elements to format for a new Table Style

s Select Element to Format


Select the next element to format and click the Format button. In our example, select ‘First
Row Stripe’ and click Format.

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.

Figure 44: Edit custom Table Style colours

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.

Figure 45: Edit custom Table Style borders

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

Figure 46: New Table Style preview

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.

Figure 47: Completed custom Table Style

7.5 MODIFYING A CUSTOM TABLE STYLE FORMAT


To modify a custom style, display the Table Styles drop down list and right-click your
custom style. From the short-cut menu, select Modify. From here the process is the same
as creating a style – select the Table Element to modify and click the Format button to
present the format options and then select your formatting preferences.

49
ANALYSE DATA WITH EXCEL TABLES Formatting Excel Tables

Figure 48: Modifying a custom Table Style format

50
ANALYSE DATA WITH EXCEL TABLES Working with Excel Tables

8 WORKING WITH EXCEL TABLES

8.1 NAVIGATING AROUND AN EXCEL TABLE


Being able to quickly select specific sections of your Table will rapidly enhance your
productivity. One method is using your mouse.

Figure 49: Selecting Tables with the Name Box

8.2 SELECTING AREAS OF AN EXCEL TABLE

Select a Row with your Mouse


To select a Table row with your mouse, move your mouse cursor to the left edge of the
row you want to select. When your mouse cursor changes to a black arrow like this ,
click to select that row.

Figure 50: Selecting a Table row with your mouse

51
ANALYSE DATA WITH EXCEL TABLES Working with Excel Tables

Select a Column with your Mouse


To select a Table column with your mouse, move your mouse cursor to the top edge of the
column you want to select. When your mouse cursor changes to a black arrow like this ,
click to select that column.

Figure 51: Selecting a Table column with your mouse

Select a Row with your Keyboard


To select a row in your Table with your keyboard, select any cell in the row you want to
select and press SHIFT+SPACE. To select the entire worksheet row, press SHIFT+SPACE
a second time. On a Mac, this is ×+SPACE.

Figure 52: Selecting a Table row with your keyboard

52
ANALYSE DATA WITH EXCEL TABLES Working with Excel Tables

Figure 53: Selecting an entire row with your keyboard

Select a Column with your Keyboard


To select a column in your Table with your keyboard, select any cell in the column you
want to select and press CTRL+SPACE (^+SPACE on a Mac). This does not select the
Heading Row or Total Row.

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.

Figure 54: Selecting a Table column with your keyboard

53
ANALYSE DATA WITH EXCEL TABLES Working with Excel Tables

Figure 55: Selecting an entire column with your keyboard

8.3 ADDING ROWS OR COLUMNS


After you have created your Table, you will often need to add more data to it.

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.

Add Columns to the right of a Table


Follow these steps to add a new column to the right of your Table:

54
ANALYSE DATA WITH EXCEL TABLES Working with Excel Tables

Figure 56: Adding a column to the right of your Table

Add Columns to the Left or Middle of a Table


Follow these steps to add a new column in the middle of your Table:

55
ANALYSE DATA WITH EXCEL TABLES Working with Excel Tables

Figure 57: Adding a column in the middle of your Table

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.

Add Rows at the end of a Table


Adding new rows at the end of your Table works the same way as adding a new column
to the right of your Table.

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

Figure 58: Adding a row at the end of your Table

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.

Add Rows in the Middle of a Table


Follow these steps to add a row in the middle of your Table:

57
ANALYSE DATA WITH EXCEL TABLES Working with Excel Tables

Figure 59: Adding a row in the middle of your Table

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.

8.4 DELETING ROWS OR COLUMNS


There are several different methods to delete columns or rows from your Table. Here we
will look at using the shortcut menu and keyboard shortcuts.

Deleting Columns or Rows via the Shortcut Menu


Using the shortcut menu (which displays when you right-click your mouse) you may delete
either a row or column via the same method.

Follow these steps to delete a row or column from your Table:

58
ANALYSE DATA WITH EXCEL TABLES Working with Excel Tables

Figure 60: Deleting Columns or Rows via the Shortcut Menu

Deleting Columns using Keyboard Shortcuts


To delete a column using a keyboard shortcut, first select a cell in the column you want
to delete and then follow these steps to delete the column:

Figure 61: Deleting Columns using Keyboard Shortcuts

Deleting Rows using Keyboard Shortcuts


To delete a row using a keyboard shortcut, first select a cell in the row you want to delete
and then follow these steps to delete a row:

59
ANALYSE DATA WITH EXCEL TABLES Working with Excel Tables

Figure 62: Deleting Rows using Keyboard Shortcuts

8.5 MOVING COLUMNS OR ROWS


You may need to rearrange the order of columns in your Table. This is not the same as
reordering columns in your worksheet, as you can rearrange Table columns without affecting
the rest of your worksheet.

Follow these steps to move columns within your Table:

Moving Columns

60
ANALYSE DATA WITH EXCEL TABLES Working with Excel Tables

Figure 63: Moving columns in your Table

Moving Rows
Follow these steps to move rows within your Table:

Figure 64: Moving rows in 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.

9.1 DISPLAYING THE TOTAL ROW IN AN EXCEL TABLE


Excel doesn’t automatically display the Total Row when you create a Table. You will need
to tell Excel you want the Total Row displayed after creating your Table.

To display the Total Row:

Figure 65: Displaying the Total Row

n Select Your Table


The first step is to select your Table or any cell in your Table.

o Check the Total Row Option


If necessary, select the Table Design tab and then check the Total Row option.

62
ANALYSE DATA WITH EXCEL TABLES Summarise with the Total Row

p Displaying the Total Row


Excel adds the Total Row and enters the ‘Total’ heading in the first cell of the Total Row.

9.2 HOW TO CHANGE THE SUMMARY FORMULA


You can quickly summarise your Table by selecting aggregations, such as AVERAGE and
SUM from a list. Excel then enters the appropriate formula on your behalf.

Figure 66: Changing th Total Row Summary Formula

n Select the Target Cell


Select the cell in the Total Row below the column you want to total. A drop-down arrow
will appear. Click the arrow to display the aggregation choices.

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

9.3 FILTERING AND THE SUBTOTAL FUNCTION


When you select one of the common aggregations from the list, Excel enters the SUBTOTAL
function in the cell for you.

Let’s take a quick look at the SUBTOTAL function:

Figure 67: The Total Row SUBTOTAL function

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:

Figure 68: The SUBTOTAL function only includes visible rows

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

10.1 COPYING & PASTING DATA TO A TABLE

Example Workbook
You can follow the examples in this section with this workbook:

\10 Managing Data in an Excel Table\Copying & Pasting


Data to a Table.xlsx

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.

Follow these steps to copy data to your Table:

65
ANALYSE DATA WITH EXCEL TABLES Managing Data in an Excel Table

Figure 69: Copying & pasting data to a Table

10.2 HOW TO REMOVE DUPLICATES FROM A TABLE

Example Workbook
The following example workbook shows examples of different Table Styles:

\10 Managing Data in an Excel Table\Remove Duplicates


from a Table.xlsx

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.

To remove duplicate rows from your Table, follow these steps:

66
ANALYSE DATA WITH EXCEL TABLES Managing Data in an Excel Table

67
ANALYSE DATA WITH EXCEL TABLES Managing Data in an Excel Table

Figure 70: Removing duplicates from a Table

n Select Your Table


First select your Table or any cell inside your Table.

o Select Remove Duplicates


From the Table Design ribbon tab, click the Remove Duplicates option.

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

11 SORTING, FILTERING &


SLICING A TABLE
Excel provides a variety of ways to ‘slice and dice’ your Table with sorting, filtering and
‘slicer’ functionality. Some sort and filter functionality is obvious, others – like sorting or
filtering by cell colour – adds an extra twist to managing your Tables.

11.1 HOW TO SORT AN EXCEL TABLE

Example Workbook
You can follow the examples in this section with this workbook:

\11 Sorting, Filtering & Slicing a Table\Sorting a Table.xlsx

We will look at two approaches to sort your Table. For the first approach, ensure the
Filter Buttons are visible in your Table:

Figure 71: Table Filter Buttons

If the Filter Buttons are not visible, then:

1. Select any cell in your Table.


2. From the Table Design ribbon tab, check the Filter Button option.

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

Figure 72: Sorting a Table via the Filter Buttons

n Select Filter Button


Click the Filter Button of the column you want to sort by. In this example, we have clicked
the Filter Button next to the ‘Units Sold’ heading.

o Select Sort Order


From the Filter Menu, select Sort Largest to Smallest.

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

Figure 73: Sorting a Table via the Data ribbon tab

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.

11.1.1 SORT BY CELL COLOUR

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:

Figure 74: Sorting a Table by cell colour

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

11.1.2 CUSTOM SORTING

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:

Figure 75: Performing a custom sort

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.

o Select Sort Options


From the Sort by drop-down list, select the first column to sort by. In this example, that
is the ‘Manufacturer’.

As we want to sort alphabetically in ascending order (A to Z), you don’t need to change
the Order option.

p Add a Sort Level


Click the Add Level button to add another column to sort by. This will display a second
row of sort options call Then by options.

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

11.2 HOW TO FILTER AN EXCEL TABLE


The steps to filter your Table are very similar to sorting. We will look at several methods
to filter your Table including filtering by colour and a custom filter

Example Workbook
You can follow the examples in this section with this workbook:

\11 Sorting, Filtering & Slicing a Table\Filtering a Table.xlsx

11.2.1 SIMPLE FILTER

First ensure the Filter Buttons are visible in your Table:

Figure 76: Table Filter Buttons

If the Filter Buttons are not visible, then:

1. Select any cell in your Table.


2. From the Table Design ribbon tab, check the Filter Button option.

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

Figure 77: Filtering a Table via the Filter Buttons

n Select Filter Button


Click the Filter Button for the column you want to filter by. In our example, that’s
‘Manufacturer’.

o Select Values to Filter by


The filter list shows all the values in this column. As we only want to see rows for one
item (Ford) a fast method is to remove the check from the Select All option and then just
select the values you do want.

p Select Filter Options


Select the values you do want to filter by, in this example, ‘Ford’.

76
ANALYSE DATA WITH EXCEL TABLES Sorting, Filtering & Slicing a Table

q Apply Filter
Click OK to apply the filter:

Figure 78: A filtered Table

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.

Figure 79: Filtering a column with many values

n Enter Filter Values


This time, start typing the first few characters of the value you want to filter by. Excel
removes values from the list which do not match your text.

o Select Filter Values


Remove the check from any values you do not want to filter (if any).

77
ANALYSE DATA WITH EXCEL TABLES Sorting, Filtering & Slicing a Table

11.2.2 FILTER BY COLOUR

Filter by colour works the same way as sort by colour. Follow these steps to filter your Table
by the colour of certain cells:

Figure 80: Filtering a Table by cell colour

n Select Filter Button


Click the Filter Button for the column you want to filter by. In our example, that’s
‘Manufacturer’.

o Select Values to Filter by


Select the Filter by Color option.

p Select Filter Options


Select the colour you want to filter by.

78
ANALYSE DATA WITH EXCEL TABLES Sorting, Filtering & Slicing a Table

11.2.2 REMOVING A FILTER

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.

The Filter Button Method


This method clears the filter for a single column. This is useful when you want to clear a
filter on one column but retain the filters on other columns.

Figure 81: Removing a Table filter

n Select Filter Button


Click the Filter Button for the column you want to remove the filter from.

o Select Values to Filter by


Select the Clear Filter From option.

The Clear Filter Method


This method is useful when you want to remove the filters from all the columns in your
Table.

79
ANALYSE DATA WITH EXCEL TABLES Sorting, Filtering & Slicing a Table

Figure 82: Clearing a Table filter

n Select Your Table


Select any cell in your Table.

o Data Tab
Select the Data ribbon tab.

p Clear Filter
Click the Clear button. This is in the Sort & Filter group.

11.3 USING SLICERS WITH AN EXCEL TABLE

Example Workbook
You can follow the examples in this section with this workbook:

\11 Sorting, Filtering & Slicing a Table\Slicers.xlsx

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.

Figure 83: An example of Table slicers

11.3.1 HOW TO FILTER A TABLE WITH SLICERS

Follow these steps to add slicers to your Table:

Figure 84: Filtering a Table with Slicers

81
ANALYSE DATA WITH EXCEL TABLES Sorting, Filtering & Slicing a Table

n Select Your Table


Select any cell in your Table.

o Insert Slicers
From the Table Design ribbon tab, select Insert Slicer.

p Select Filter Options


Excel presents a list of columns in your Table. Select the columns you want to add slicers for.

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.

Figure 85: Moving & resizing Table Slicers

82
ANALYSE DATA WITH EXCEL TABLES Sorting, Filtering & Slicing a Table

11.3.2 ANATOMY OF A SLICER

There are several options on the slicer box worth knowing about. Let’s take a look at them:

Figure 86: Anatomy of a Table Slicer

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.

11.3.3 FORMATTING SLICERS

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:

Figure 87: Formatting Table Slicers

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

12.1 STRUCTURED REFERENCES IN EXCEL TABLES

Example Workbook
You can follow the examples in this section with this workbook:

\12 Analysing Tables with Formulas\Analysing Tables with


Formulas.xlsx

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:

Figure 88: Standard formula structure

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.

The reference in this example is comprised of a worksheet reference o and a reference to


a range of cells p. The worksheet and range of cells are separated by an exclamation mark
(!). Often the worksheet name (such as ‘Sheet1’) and range (such as ‘A1:P4567’) give no
indication what the data represents.

Now let’s look at a simple formula for a Table:

Figure 89: Table formula with structured reference

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:

Figure 90: Reference specific Table elements in a formula

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

Figure 91: Table formula Intellisense

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

12.2 HOW TO TURN OFF STRUCTURED REFERENCING


Many people find formulas with structured references easier to write, read and debug.
But not everyone. If you prefer your formulas to use regular cell references, the structured
references can be switched off. To turn off structured references, follow these steps:

Figure 92: Turning off structured references

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

p Table Names in Formulas


Remove the check from the Use table names in formulas option.

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:

Figure 93: Comparing formulas with & without structured references

12.3 CREATING FORMULAS INSIDE AN EXCEL TABLE


Before we look at some formulas you can apply to a Table, let’s look at creating a formula
inside a Table.

90
ANALYSE DATA WITH EXCEL TABLES Analysing Tables with Formulas

Example Workbook
You can follow the examples in this section with this workbook:

\12 Analysing Tables with Formulas\Creating Formulas inside


a Table.xlsx

Figure 94: Creating Formulas inside an Excel Table

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.

Figure 95: Current row formula notation

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.

12.4 USING COUNTIF FORMULAS WITH TABLES

Example Workbook
You can follow the examples in this section with this workbook:

\12 Analysing Tables with Formulas\Using COUNTIF with


Tables.xlsx

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

In cell B3 enter ‘=’ and then start typing


‘UN’, then press the down-arrow to select
the unique* function and press tab.

Starting typing the name of our


‘Countries’ Tables. Excel will display
the name amongst other function
and range names.

Use the down-arrows to select it and


press tab.

Open a square bracket. Excel will display


the Table sections. Use the arrow keys
to select ‘Region’.

Enter a close square bracket, then a


closing parenthesis and press enter.
Excel enters a distinct list of regions
from the ‘Countries’ Table.

*UNIQUE is only available with Excel 365 and higher.

94
ANALYSE DATA WITH EXCEL TABLES Analysing Tables with Formulas

Now let’s count how many times each


region appears.
In cell C3 enter ‘=’ and then type
‘countif ’ and open a parenthesis.

As before, starting typing the name


of our ‘Countries’ Table then select it
from the list.
Open a square bracket, use the arrow
keys to select ‘Region’ and press tab
to select it.
Then type a closing square bracket
and a comma.

Press the left-arrow key to select the


region in the cell to the left. Enter a
closing parenthesis and press enter.

As this is not a Table, the formula is


not copied down automatically.
To copy the formula down, hold the
mouse cursor over the handle at the
lower-right corner of the cell, the
double-click your mouse.

95
ANALYSE DATA WITH EXCEL TABLES Analysing Tables with Formulas

The double-click triggers AutoFill to


copy the formula down until the list
on the left ends.

12.5 USING SUMIF FORMULAS WITH TABLES

Example Workbook
You can follow the examples in this section with this workbook:

\12 Analysing Tables with Formulas\Using SUMIF Formulas


Tables.xlsx

In cell C3 enter ‘=’ to start a formula, then


sumif followed by an open parenthesis.
Then enter the name of the Table,
‘Countries’ in our example, followed by
an open square bracket.
From the Intellisense list select
‘Region’ and press tab.

Press the left-arrow key to select the


region in the cell to the left.
You now have the criteria range and
condition entered. Next you select the
values to sum.

96
ANALYSE DATA WITH EXCEL TABLES Analysing Tables with Formulas

Enter the name of the Table again


followed by a square bracket.
From the Intellisense list select
‘Population’ and press tab.

Your formula should now look like this.


Press enter.
The formula says; “where the region
is ‘Asia’, sum the population in the
Countries Table”.

To copy the formula down, hold the


mouse cursor over the handle at the
lower-right corner of the cell, then
double-click your mouse.

The double-click triggers AutoFill to


copy the formula down until the list
on the left ends.

12.6 USING VLOOKUP FORMULAS ON AN EXCEL TABLE


As you would expect, you can also write VLOOKUP formulas to retrieve values from a Table.

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:

\12 Analysing Tables with Formulas\Using VLOOKUP with


Tables.xlsx

Figure 97: Using VLOOKUP with Tables example

n Data Validation List


This drop-down list of values uses Excel’s Data Validation feature to provide a dynamic list
of values from your Table.

o VLOOKUP Formulas
VLOOKUP formulas to retrieve values from your Table based on the Country selected
from the drop-down list.

The Drop-Down List


For the drop-down list we will use Excel’s Data Validation feature. But a quick word about
how you can reference a Table column from the Data Validation list formula.

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])”)

Create a Data Validation Drop-Down List from a Table column


To create the drop-down list from a Table column, follow these steps:

In the VLOOKUP worksheet select cell C2


where the drop-down list will be created.
From the Data ribbon tab, select Data
Validation.

From the Allow drop-down, select ‘List’.


Then in the Source field enter the formula:
=INDIRECT(“Countries[Country]”)
Finally, click OK.

When you now select cell C2, an arrow


will appear to the right of the cell. Click
this to display a list of countries.
99
You can now use the selected country for
ANALYSE DATA WITH EXCEL TABLES Analysing Tables with Formulas

When you now select cell C2, an arrow


will appear to the right of the cell. Click
this to display a list of countries.
You can now use the selected country for
your VLOOKUP formulas.

Now that you have a list of countries in a drop-down list, let’s enter a VLOOKUP formula
which references the Table.

In cell C3 enter the following formula:


=VLOOKUP($C$2, Countries, 2, FALSE)

The press ENTER.

Note that we’ve ‘locked in’ the reference to


the country in cell C2 with dollars signs.

You can either type these or press F4 to


have Excel enter them for you.

The VLOOKUP formula should return the


region for the currently selected country.

Now copy the formula down using your


preferred copy method

Finally, you will notice each formula returns


the same value.

This is because the Column Index Number


parameter needs to be changed for each
VLOOKUP formula.
100
ANALYSE DATA WITH EXCEL TABLES Analysing Tables with Formulas

Finally, you will notice each formula returns


the same value.

This is because the Column Index Number


parameter needs to be changed for each
VLOOKUP formula.

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.

12.7 DYNAMICALLY REFERENCE COLUMNS WITH VLOOKUP

Example Workbook
You can follow the examples in this section with this workbook:

\12 Analysing Tables with Formulas\Dynamically Reference


Columns with VLOOKUP.xlsx

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

Figure 98: Table VLOOKUP with static column reference

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.

Figure 100: Using the MATCH function to create a dynamic reference

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:

Figure 101: Table VLOOKUP with dynamic column reference

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!).

13.1 CONNECTING TABLES


Essentially, you are going to connect or ‘map’ one Table to another using a column that is
common between them.

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:

\13 Working with Multiple Tables\Working with Multiple


Tables.xlsx

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.

Figure 102: Connecting Tables with Relationships

13.2 CREATING RELATIONSHIPS BETWEEN TWO TABLES


To collate the data from across the Tables, you need to create ‘relationships’ between them
using a column common to them both.

This is done via the Relationships button on the Data ribbon tab which has the following
options:

Figure 103: Creating a Relationship between two Tables

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.

Related Column (Primary)


The name of the column (with the matching values) you want to connect with. Because these
values are unique, they are sometimes called a ‘Unique Identifier’, ‘Key’, or – in relational
database lingo – a ‘Primary Key’.

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.

Create a Table Relationship


To create relationship between Tables, follow the steps below. This example uses the Tables
in the example workbook.

106
ANALYSE DATA WITH EXCEL TABLES Working with Multiple Tables

From the Data tab select


Relationships. This will
display the ‘Manage
Relationships’ screen (left).

Then click New.

From the Table list select


‘Sales’ and ‘Employee’ from
the Column (Foreign) list.

From the Related Table


list select ‘Employees’ and
‘Employee ID’ from the
Related Column (Primary)
list.

Then click OK.

The first relationship has been


created.

Click New again to create the


next relationship.

107
ANALYSE DATA WITH EXCEL TABLES Working with Multiple Tables

From the Table list select


‘Sales’ and ‘State’ from the
Column (Foreign) list.

From the Related Table


list select ‘States’ and ‘State’
from the Related Column
(Primary) list.

Then click OK.

The second relationship has


been created.

You can now collate data


from all 3 Tables given these
two relationships.

13.3 CREATING A SINGLE REPORT FROM MULTIPLE TABLES


You can now create a PivotTable to collate or combine the data from multiple Tables with
relationships.

Create a Report from Related Tables


To create a PivotTable report from multiple, related Tables, follow the steps below.

108
ANALYSE DATA WITH EXCEL TABLES Working with Multiple Tables

From the Insert ribbon tab, select


PivotTable.

The most common source is a Table


or range, but in this example, we
will select ‘Use this workbook’s Data
Model’.

Then click OK.

In the PivotTable Fields list, where


you normally only see a list of fields
(columns), you now have a list of
Tables.

Click the ‘>’ symbol to expand each


Table to view the available columns.

The PivotTable Fields pane will allow you to select fields from all the Tables which are
connected like the example below:

Figure 104: A PivotTable report based on multiple Tables

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

14.1 HOW TO ADD AN ID COLUMN OF SEQUENTIAL NUMBERS

Example Workbook
You can follow the examples in this section with this workbook:

\14 Advanced & Sneaky Techniques\Add an ID Column of


Sequential Numbers.xlsx

There’s several ways to add a column of sequential numbers to your Table.

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.

Figure 105: Adding an ID column with AutoFill

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

Figure 106: Using the ROW function for ID columns

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.

The complete formula is structured like this:

=ROW() - ROW(TableName[[#Headers], [ColumnName]])

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:

=ROW() - ROW(Carbon[[#Headers], [ID]])

Here’s an example:

Figure 107: Adding a dynamic ID column with the ROW function

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:

=ROW() - ROW(Carbon[[#Headers],[ID]]) + 999

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.

=”CAR” & ROW() - ROW(Carbon[[#Headers],[ID]])

Figure 108: Adding extra characters to an ID column

14.2 HOW TO ADD A RUNNING TOTAL TO A TABLE

Example Workbook
You can follow the examples in this section with this workbook:

\14 Advanced & Sneaky Techniques\Add a Running Total


to a Table.xlsx

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

The complete formula is structured like this:

=SUM(TableName[[#Headers],[ColumnName]]:[@[ColumnName]])

Here’s an example:

Figure 109: Adding a ‘running total’ to a Table

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.

The structure for this formula is:

=SUMIF(TableName[[#Headers],[Test Column]]:[@Test Column],


[@Test Column], TableName[[#Headers],[Sum Column]]:[@Sum Column])

Here’s an example included in example workbook you can download:

=SUMIF(Carbon2[[#Headers],[Region]]:[@Region],[@Region],Carbon2[[#Headers],[Billi
on Tons]]:[@[Billion Tons]])

114
ANALYSE DATA WITH EXCEL TABLES Advanced Techniques

Figure 110: The structure of the running total formula

Filtering the list, you can quickly confirm with the Status Bar totals that the conditional
running total is correct:

Figure 111: Confirming your running total is correct

14.3 HOW TO PREVENT DUPLICATE VALUES IN A COLUMN

Example Workbook
You can follow the examples in this section with this workbook:

\14 Advanced & Sneaky Techniques\Prevent Duplicate Values


in a Column.xlsx

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:

Figure 112: Preventing duplicate values in a Table column

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’:

Figure 113: Naming the Table column to prevent duplicates in

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

Figure 114: Entering the Data Validation formula to prevent duplicates

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:

Figure 115: Example error message to prevent duplicates in a column

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

15.1 KEYBOARD SHORTCUTS FOR WORKING WITH TABLES


Excel has over 230 keyboard shortcuts. If you prefer using a keyboard to a mouse, you can
get things done a lot faster.

The table below lists keyboard shortcuts specifically for working with Excel Tables, including
both Windows and Mac versions.

Task Windows Mac

Insert Table Ctrl T ^ T

Toggle AutoFilter Ctrl Shift L a × F

Activate the filter Alt ↓ Ⴆ ↓

Select Table row Shift Space × Space

Select Table column Ctrl Space ^ Space

Select Table Ctrl A a A

Clear the slicer filter Alt C Ⴆ C

Toggle the Table Total row Ctrl Shift T a × T

119

You might also like