Chapter 6 Creating, Sorting, and Querying a Table Microsoft Excel 2013
Dec 14, 2015
Creating, Sorting, and Querying a Table 2
• Create and manipulate a table• Delete duplicate records• Add calculated columns to a table with structured
references• Use the VLOOKUP function to look up a value in a
table• Use icon sets with conditional formatting• Insert a total row• Sort a table based on one field or multiple fields
Objectives
Creating, Sorting, and Querying a Table 3
• Sort, query, and search a table using AutoFilter• Remove filters• Create criteria and extract ranges• Apply database functions, such as SUMIF and
COUNTIF• Use the MATCH and INDEX functions to look up a
value in a table• Display automatic subtotals• Use outline features to group, hide, and unhide data
Objectives
Creating, Sorting, and Querying a Table 5
Creating a Table
• A table, also called a database, is an organized collection of data
• The data related to each person or item is called a record, and the individual data items that make up a record are called fields
• When creating a table in Excel, you should not enter more than one table per worksheet.
Creating, Sorting, and Querying a Table 7
• Row banding causes adjacent rows to have different formatting so that each row in the table is distinguished from surrounding rows
Formatting a Table
Creating, Sorting, and Querying a Table 8
Using a LOOKUP Table
• Excel contains functions that allow you to search for values in a secondary, or lookup table.
Creating, Sorting, and Querying a Table 9
Using a LOOKUP Table
• The two most widely used lookup functions are HLOOKUP and VLOOKUP
• Both functions look up a value in a lookup table and return a corresponding value from the table to the cell containing the function
• The HLOOKUP function is used when the table direction is horizontal, or across the worksheet
• The VLOOKUP function is used when a table direction is vertical, or down the worksheet
Creating, Sorting, and Querying a Table 10
Adding Conditional Formatting
• Conditional Formatting allows you to create rules that change the formatting of a cell or range of cells based on the value of a particular cell
• Excel includes five types of conditional formats: highlight, top and bottom rules, data bars, color scales, and icon sets.
Creating, Sorting, and Querying a Table 11
The Conditional Formatting Rules Manager• The Conditional Formatting Rules Manager dialog box allows you
to view all of the rules for the current selection or for an entire worksheet and change the order in which the rules are applied to a cell or range
Creating, Sorting, and Querying a Table 12
Inserting a Total Row
• The Total Row check box, found in the Table Tools Design tab, allows you to insert a total row at the bottom of the table
• The default setting creates a total in the column, however, total rows display a button beside each cell to create other totals and functions
Creating, Sorting, and Querying a Table 14
Sorting a Table in Ascending Sequence• Arranging records in a specific sequence is called sorting• Data is in ascending order if it is sorted from lowest to
highest, earliest to most recent, or alphabetically from A to Z
Creating, Sorting, and Querying a Table 15
Sorting a Table in Descending Sequence• Data is in descending order if it is sorted from highest to
lowest, most recent to earliest, or alphabetically from Z to A
Creating, Sorting, and Querying a Table 16
Custom Sorting a Table
• If the column you choose to sort includes numeric data, then the Sort & Filter menu would show the ‘Sort Smallest to Largest’ and ‘Sort Largest to Smallest’ commands instead of the ‘Sort A to Z’ and ‘Sort to A’ commands
Creating, Sorting, and Querying a Table 17
Sorting a Table Using AutoFilter
• When you first create a table, Excel automatically enables AutoFilter, a method to sort, query, and filter the records in the table
• Filter buttons appear to the right of the column headings
• Clicking a button displays the filter menu for the column with various commands and a list of all items in the field
Creating, Sorting, and Querying a Table 18
Querying a Table Using AutoFilter
• The process of filtering activity based on one or more filter criteria is called a query
• You can apply more than one filter at a time• When you apply a second filter criterion, Excel adds it to the first and
now each record must pass two tests to appear as part of the final subset of the table
Creating, Sorting, and Querying a Table 19
Searching a Table Using AutoFilter
• You can search a table using wildcard characters
• In the Search box, you can type a ? (question mark) to represent any single character
• For example, type answer? to display results such as answer1, answer2, and answer3
• Another way to search includes using an * (asterisk) to represent a series of characters
• For example, type *drive* to display results such as flash drives, CD-R drive, and drivers
Creating, Sorting, and Querying a Table 20
Querying Using a Criteria Range
• Another advanced filter technique called a criteria range manipulates records that pass comparison criteria
• Like a custom filter, a criteria range compares entered data with a list or table, based on column headings and then extracts those records
Creating, Sorting, and Querying a Table 22
Extracting Records
• You also can create an extract range in which Excel copies the records that meet the comparison criteria in the criteria range to another part of the worksheet
• Extracting records allows you to pull data from a table so that you can analyze or manipulate the data further
Creating, Sorting, and Querying a Table 24
• If the criteria range contains a blank row, it means that no comparison criteria have been defined. Thus, all records in the table pass the test and will be displayed.
• If you want an OR operator in the same field, your criteria range must contain two (or more) data rows. Enter the criteria data on separate rows. Records that pass either comparison criterion will be displayed.
• If you want an AND operator in the same field name, you must add a column in the criteria range and duplicate the column heading.
• If you want an OR operator on two different fields, your criteria range must contain two (or more) data rows. Enter the criteria for each field on a separate row. Records will display that pass either comparison criterion.
• When the comparison criteria below different field names are in the same row, then records pass the test only if they pass all the comparison criteria. If the comparison criteria for the field names are in different rows, then the records must pass only one of the tests.
Different Comparison Criteria
Creating, Sorting, and Querying a Table 25
Using the DAVERAGE and DCOUNT Database Functions• The DAVERAGE function finds the average
of numbers in a table field that pass a test• The DCOUNT function will count the
number of numeric entries in a table field that pass a test
• With the desired cell selected, type the DAVERAGE function or DCOUNT function– Ex: =daverage(a8:j21,
“Experience”,o2:o3) – Ex: =dcount (a8:j21,
“Experience” q2:q3)
Creating, Sorting, and Querying a Table 26
Using the SUMIF Function
• The SUMIF function sums values in a range only if they meet the criteria
• With the desired cell selected, type the SUMIF Function– Ex: =sumif(j9:j21, ”Gold”, h9:h21)
Creating, Sorting, and Querying a Table 27
Using the COUNTIF Function
• The COUNTIF function counts values in a range only if they meet the criteria
• With the desired cell selected, type the COUNTIF function– Ex: =countif(b9:b21, ”Residential”)
Creating, Sorting, and Querying a Table 28
Using the MATCH and INDEX Functions• The MATCH function tells you the relative position of an
item in a range or table, which matches a specified value in a specified order
• The INDEX function returns the value or reference of the cell at the intersection of a particular row and column in a table or range
Creating, Sorting, and Querying a Table 30
Displaying Subtotals
• Another way to summarize data is by using subtotals. A subtotal is the sum of a subset of data, and a grand total sums all of the data in a row or column
Creating, Sorting, and Querying a Table 31
Using the Outline Feature
• The subtotal command displays outline symbols beside the rows or above the columns of the data you want to group
• The outline symbols include plus and minus signs for showing and hiding portion of the spreadsheet, as well as brackets identifying the groups
• Excel turns on the outline feature automatically when you create subtotals