Excel 2016: Large Data 1 : Sorting and Filtering
Excel 2016: Large Data 1 : Sorting and Filtering
Excel 2016: Large Data 1 ‐
Sorting and Filtering
[email protected]
Excel 2016: Large Data 1 ‐ Sorting and Filtering
1.5 hours
In this workshop we will work with single and multilevel sorting; learn to use data
filters to automatically show only the specified data set; and do math on our
filtered data sets. This workshop also contains a very brief introduction to other
summary tools such as Subtotal and Pivot Tables. This intermediate workshop
assumes prior experience with Microsoft Excel.
Sorting Data ................................................................................................... 1
Ascending Sorts .......................................................................................... 1
Descending Sorts ........................................................................................ 1
Custom Sorts .............................................................................................. 1
Custom Lists ................................................................................................ 2
Sort Options ................................................................................................ 2
Filtering Data ................................................................................................. 3
Custom Filters ............................................................................................. 4
SUBTOTAL Worksheet Function ..................................................................... 5
Other Summary Tools .................................................................................... 6
Subtotal Outlines ........................................................................................ 6
Pivot Tables ................................................................................................ 6
Class Exercise ................................................................................................. 7
SubTotal Worksheet Function Exercise........................................................ 17
Pandora Rose Cowart
Education/Training Specialist
UF Health IT Training
C3‐013 Communicore (352) 273‐5051
PO Box 100152 [email protected]
Gainesville, FL 32610‐0152 http://training.health.ufl.edu
Updated 11/02/2016
Sorting Data
On the far right side of the Home tab you will find a large Sort & Filter
button. The menu you see when you click on the button is reflected in
the Sort & Filter group of the Data tab.
If you make a selection of cells, Excel will think you only want to sort or
filter by that selection. But if your
dataset has no blank rows and no
blank columns Excel will see the
whole range as one data set.
You can have blank cells, but not completely blank columns/rows; if
you are not sure that your dataset is consistent, click inside one cell, and press Ctrl‐A. This will select all
the cells within the dataset. A second "Ctrl‐A", or pressing the shortcut in an empty cell, will select the
entire sheet.
When you have completed a sort, you can click the Undo button (or Ctrl‐Z). Excel will undo the sort and
it will select the dataset it used in the sort. This is another way to see your dataset.
Ascending Sorts
‐ Text: Sort alphabetically from A to Z
‐ Numbers: Sorts from smallest number to largest number
‐ Dates: Sorts from the newest date to the oldest date
Descending Sorts
‐ Text: Sort alphabetically from Z to A
‐ Numbers: Sorts from largest number to smallest number
‐ Dates: Sorts from the oldest date to the newest date
Custom Sorts
When you first open this window, Excel will show the most recent sort options. If you haven't created a
sort yet, this window may be blank.
In Excel 2016, we can sort by 64 levels. From this sort window we can add levels, delete levels, copy
levels, and even change the order of our sort using the up and down arrows in the toolbar.
1
Column: The column drop‐down menu will show the names of your columns, your 'fields'. If your data
doesn't have titles Excel lists the column heading letters instead. If you were expecting titles, but is only
showing the column letters, you can click on the check box in the upper right hand corner of the Sort
window to let Excel know your data has headers.
Sort On: You can Sort on the values of the cells, the cell colors, the font
colors, or the cell icons.
Order: The order options change depending on the values in the cells.
Text Number Date
Font Color Cell Color
Custom Lists
Custom lists can be built through the
Excel Options under the File menu in
the Advanced section under General.
Or by choosing Custom List… option at
the bottom of each order box above.
If you choose this option, you will be
able to select from one of these lists.
Alphabetically, April comes before
January. With the Custom List order, we
can ensure January comes first.
These custom lists will work as patterns
with the fill handle. Notice the
"Shopping" list? Once I set this up, I can
type any of the words in a cell and use
the fill handle to follow this pattern.
Sort Options
‐ Case sensitive: Sort lowercase letters before uppercase letters
‐ Orientation: Sort vertically (top to bottom, sort rows) or horizontally
(left to right, sort columns)
2
Filtering Data
Filters hide rows (records) based on criteria you set. You can turn the filter on
and off by choosing Filter from the Sort & Filter button on the Home tab, or
choosing the Filter button on the Data tab.
Excel will place a drop‐down arrow at the end of each cell in the title row
(the first row of the dataset). When you click on this arrow we see several
options including our sort orders:
Sort Ascending, Descending, and by color
Clear the Filter
Filter by Color
Set a custom filter (text, number, date)
Search for a matching value in the column
List of values in the column (field). Select All will toggle
between everything and nothing.
Once a filter has been set Excel will hide all the rows that don't match the criteria. The status bar will
show how many records (rows) were found that matched. The row numbers of the original data will
remain the same, but will appear blue. The dropdown arrows of the columns that are being filtered will
show the filter icon (funnel). The double line between the row numbers indicate hidden rows.
3
Custom Filters
Depending on the data in the column you will have the option to set a custom filter based on text,
numbers, and dates.
Text Filters Number Filters Date Filters
If you choose one of the options on the Filter List with the ellipsis (…), you
will see a Custom Auto Filter window such as this. From here we can set up
to two filters.
Be careful with the AND/OR relationships. If you ask Excel to show the rows where the City equals
Jacksonville AND the City equals Gainesville, you will get no results, because one cell cannot equal both
values. But if you ask for the same using the OR, Excel will show all the records for both cities. Or's tend
to work for exact matches (Equals This OR Equals That), whereas AND's tend to work for ranges (Greater
than This AND Less than That).
You can use the "Wildcards" ? and * to help you with your filter. ? is used for one character, * for
multiple.
Equals Jacks* ‐> Jacksonville, Jacksonville Beach, Jackson Heights
Some of the filter choices may work just as well. I could say Contains 'Jacks' or Begins with 'Jacks'.
4
SUBTOTAL Worksheet Function
We can do common mathematical functions with our filtered lists using the SUBTOTAL worksheet
function. The syntax is for this function is "SUBTOTAL(function_num,ref1,ref2,...)". Function_num is the
number 1 to 11 that specifies which 'function' to use in calculating subtotals within a list (see below).
The ref1, ref2… are the ranges of data that should be used in the equation, there can be up to 29
different ranges used in this function.
Function numbers 1 through 11 will include manually‐hidden rows, ones you have hidden yourself.
Function numbers 101‐111 will exclude your hidden rows from the function. Filtered‐out rows are
always excluded.
5
Other Summary Tools
Subtotal Outlines
One way to sum up a large set of data is to use the
Subtotal tool in the Outline group of the Data tab. This
tool will total sets of related data and insert a subtotal
row into the sheet at each change in the column of your
choosing. It will also create a grand total at the bottom
of the dataset.
This tool is very particular about your sort order. If you
are going to group a column, make sure it is sorted first.
Also pay attention to the Replace Current Subtotals
option, as it does erase the previous totals.
Excel adds outline symbols to the
left side of the worksheet. The
numbers represent the outline level,
the plus is used to expand a group,
and the minus is to collapse a group.
Pivot Tables
Another amazing summary tool built into Microsoft
Excel is the Pivot Table. You'll find this button at the
beginning of the Insert tab.
By default, this tool will create a new sheet with a blank
table on it. You can use the Pivot Table field list to
decide where your field names (titles) should be placed
as labels and summarizing the values as needed.
Every field of the pivot table can be filtered, and once
you have multiple levels as seen below, you will see the
collapse/expand buttons as with the Subtotal Outline.
6
Class Exercise
‐ Open file SortCustomers.xlsx
Simple Sorts
‐ Click in the title CITY in cell D1
‐ Home Tab ‐> Sort and Filter ‐> Sort A to Z (ascending)
‐ Undo
‐ Sort is "undone" and selection that was sorted is highlighted
‐ Select Column D (city)
‐ Home Tab ‐> Sort and Filter ‐> Sort A to Z (ascending)
‐ Say OK to the message
‐ Undo
Default Sort Order
‐ Right‐click Column A (LAST)
‐ Insert a Column
‐ Title the new column SORT (A1)
‐ In A2 type: 1
‐ In A3 type: 2
‐ Select both numbers
‐ Double‐click the fill handle to copy the pattern to the end of the data set
‐ Sort by CITY
‐ Sort by SORT
‐ Delete Column A
Blank Columns
‐ Select Column B (FIRST)
‐ Insert a Column
‐ Sort by CITY Z to A (descending) ‐ Notice the first and last names no longer match up
‐ Undo ‐ Notice the last name column is left out of the group
‐ In B1 type: SUFFIX
‐ Sort by City Z to A
‐ Undo until the new column (SUFFIX) is gone
7
Custom Sort ‐ Multiple levels
‐ Click on the large sort button on the Data tab
‐ Set the sort order for CITY, BALANCE, and DUE DATE
‐ Use the Add Level buttons to create new lines
‐ View the Results
Custom Sort ‐ Rearranging
‐ Open the Custom Sort again
‐ Select the DUE DATE row and use the arrows to move it
‐ Set the sort order for CITY, DUE DATE, and BALANCE
‐ View the Results
Custom Sort ‐ Resetting
‐ Click in the Column A (LAST)
‐ Click the Ascending button
‐ Open the Custom Sort window
‐ Sort order has been reset
8
Custom Sort ‐ by Color
‐ Open the Custom Sort window
‐ Sort by Address, Sort on Cell Color, Order Green On Top
‐ Copy Level and set the Order to Peach on top
‐ Add Level ‐> Balance, smallest to largest
‐ View the Results
Reset to our default sort order
‐ Click in the column A (LAST)
‐ Click the Ascending button
Custom Sort ‐ Left to Right
‐ Open Custom Sort Window
‐ Click on the Options… button
‐ Change orientation to Sort left to right
‐ Click OK
‐ Sort by Row 1, A to Z
‐ Columns have rearranged to Address through Zip
9
Custom Sort ‐ Left to Right
‐ Select Row 2, and Insert a row
‐ Number the cells: 3, 8, 4, 7, 1, 2, 5, 6
‐ Open Custom Sort Window
‐ Sort by Row 2
‐ View the result
Custom Sort ‐ Left to Right ‐ Selection
‐ Select Columns A and B (FIRST and LAST)
‐ Open Custom Sort window
‐ Sort by Row 2, Largest to Smallest
‐ Repeat for Columns G and H (DUE DATE and BALANCE)
‐ Delete Row 2
Reset to our default sort order
‐ Click in the Column A (LAST)
‐ Click the Ascending button
‐ Title row disappears
‐ LAST has shuffled down to the L's
‐ Undo the sort
My data has headers
‐ Open the custom sort window
‐ Sort by only lists the column letters for the 8 columns in our dataset
‐ (if it is still offering rows, change the options)
‐ In the upper right of the window click the My data has
headers checkbox
‐ Sort by LAST, A to Z
10
Start over
‐ Exit Microsoft Excel
‐ DO NOT SAVE
Instant Filter
‐ Open SortCustomers.xlsx
‐ Right‐click on a city of Waldo
‐ Choose Filter ‐> Filter by Selected Cell's Value
*** Filter arrows appear on all columns of the data set
*** All rows not matching the criteria have disappeared
*** Row numbers turn blue, but maintain original cell numbers
*** Bottom of the window shows how many records (rows) match
Turn the Filter Off
‐ From the Sort & Filter button on the Home tab, choose Filter
*** All filter signs will disappear
Filter by Unchecking
‐ Click the large Filter button on the Data tab
‐ From the City drop down, uncheck Jacksonville, click OK (67 records)
‐ From the City drop down, uncheck Gainesville, click OK (12 records)
‐ From the City drop down, check Select All, click OK
11
Filter by (Un)Select all
‐ from the Zip drop down
‐ uncheck Select All
‐ check 32608
‐ click OK (12 records)
Adding another filter
‐ Keep the 32608 filter
‐ from the City drop down, uncheck Jacksonville
‐ click OK (9 records)
‐ from the Data tab, choose the filter Clear button
Custom number filter
‐ Balance drop down
‐ choose Number Filter
‐ choose Less than, type in 100
‐ click OK (12 records)
‐ Clear the filter
Date filter
‐ Due Date drop down
‐ uncheck Select All
‐ use the expand (+) buttons to open the dates
‐ check the first three months of 2016
‐ click OK (11 records)
Custom date filter
‐ From the Due Date drop down, choose Date Filters
‐ Choose Between
‐ type in 7/1/2016, type in 6/30/2017
‐ click ok (23 records)
‐ Clear the filter
12
Custom text filter
‐ From the Last drop down, choose Text Filter
‐ Choose Begins with, type J
‐ click ok (10 records)
‐ From the Last drop down, choose Text Filter
‐ Choose Ends with, type S
‐ click ok (21 records)
‐ From the Last drop down, choose Text Filter
‐ Choose Begins with, type J
‐ On the second line choose Ends with, type S
‐ click ok (6 records)
‐ From the Last drop down, choose Text Filter
‐ Choose Custom Filter
‐ Change the bubble (radio button) to OR
‐ click ok (25 records)
‐ Clear the filter
Custom text filter
‐ From the Address drop down, choose Text Filter
‐ Choose Contains, type Box
‐ Excel is not case sensitive. BOX = Box = box
‐ click ok (12 records)
‐ Clear the filter
Search filter
‐ From the Address drop down, click inside the Search box
‐ Type box
**** Type it slowly, one letter at a time to see the list
get smaller as you go
‐ Click ok (12 records
‐ Clear the filter
13
Filter by Color
‐ From the Address drop down, choose Filter by color
‐ Choose the green addresses (13 records)
‐ Clear the filter
Refreshing Filtered Data
‐ From the Balance drop down, choose Number Filter
‐ Choose Greater Than, type 600
‐ click ok (4 records)
‐ Change Edgar's balance to 300
‐ From the Data tab, choose the filter Refresh button (3 records)
‐ Clear the filter
Copying filtered data
‐ Use the filter tools to find these 7 records: ‐ Use the filter tools to find these 9 records:
‐ Balance under 300 ‐ Balance under 350
‐ Address color has no fill ‐ Address color has no fill
‐ Due Date in 2018 ‐ Due Date in 2017
‐ Select All, Copy ‐ Select All, Copy
‐ Create a new worksheet ‐ Turn to Sheet 2
‐ Paste in Cell A1 ‐ paste in Cell A11
‐ Return to Sheet 1 and Clear the filter
Notice the copy lines don't go between contiguous rows.
‐ In Sheet 2, Select ALL of the sheet
‐ AutoFit the column widths
‐ Double‐click between column headings
14
Filter on one data set
‐ Move to Cell A1 (Ctrl Home)
‐ Turn on the filter
‐ From the City drop down, uncheck Gainesville
‐ click ok (4 records)
****Gainesville only disappears from the first list because of the gap
‐ Turn off the filter
Filter on multiple data sets
‐ Select all the data columns (not just the data, all the columns A:H)
‐ Turn on the filter
‐ Autofit again
‐ From the City drop down, uncheck Gainesville
‐ click ok (6 people)
****Gainesville disappears from both lists, but the record count is wrong
‐ Clear the filter
Filter including gap
‐ From the City drop down, uncheck Select All
‐ From the City drop down, check Gainesville
‐ From the City drop down, check (Blanks)
‐ From the City drop down, check City
‐ From the City drop down, uncheck Gainesville
‐ From the City drop down, check Jacksonville
Start over
‐ Exit Microsoft Excel
‐ DO NOT SAVE
15
Set up Grand Total
‐ Open file SortCustomers.xlsx
‐ Turn on the Filter
‐ Go to Cell H79, Type SubTotal
‐ Go to Cell H80, Type Total
‐ Go to Cell G80, press the AutoSum button ∑ (on the Home or Formulas tab)
‐ Modify equation to stop at row 78
**** =SUM(G2:G78)
‐ Result: $23,192.00
Set up SubTotal
‐ Return to the top of the worksheet (Ctrl‐Home)
‐ Set City filter to show only Waldo
‐ Go to Cell G79, press the AutoSum button ∑
**** See Page 5 for details on the SubTotal Worksheet Function
‐ Result: $2,325.00
Viewing the different Subtotals
‐ From the City drop down, set it so you can only see Starke
‐ Result: $1,290.00
‐ From the City drop down, set it so you can only see Jacksonville
‐ Result: $3,506.00
‐ From the City drop down, set it so you can only see Gainesville
‐ Result: $16,071.00
‐ Clear the filter
Start over
‐ Exit Microsoft Excel
‐ DO NOT SAVE
16
SubTotal Worksheet Function Exercise
‐ Open file SortSales.xlsx
1) Insert four rows at the top of the worksheet
a. Select the first four rows
b. Right‐click inside the select and choose INSERT
2) Create this table:
3) Click inside the dataset, turn on the Filter
4) Use the filter tools to find these 3 records:
‐ Quarter: 2nd Quarter
‐ Item: Pants
‐ Color: Red
5) Build the following equations
You have to go above and below the showing numbers so that you include all the hidden cells!
6) View Page 5 for the "answers"
7) Clear the filter, the numbers in Column E should match the numbers in Column B
17