Excel 2007 - Database Functions & Scenarios

advertisement
Microsoft®
Database Functions & Scenarios
Amarillo College
Revision Date: July 1, 2008
Table of Contents
NAMING RANGES .................................................................................................................................................. 1
CHANGING A RANGE NAME .............................................................................................................................................1
DATABASE FUNCTIONS IN EXCEL ........................................................................................................................... 2
=DSUM ......................................................................................................................................................................3
=DAVERAGE ..............................................................................................................................................................5
=DCOUNT ..................................................................................................................................................................5
=DMAX & =DMIN.......................................................................................................................................................5
SCENARIOS ............................................................................................................................................................ 6
VIEWING A SCENARIO .....................................................................................................................................................7
VIEWING A SCENARIO SUMMARY ......................................................................................................................................7
LOOKUP TABLES..................................................................................................................................................... 8
i
Microsoft Excel 2007
Database Functions & Scenarios
NAMING RANGES
Some of the advanced functions require ranges to be named before the function will work
properly.
1. Highlight the range.
2. Click in the Name box (illustrated below) and type the new name for the range.
a. The name cannot contain a space
b. The name cannot be the name of a cell
Changing a Range Name
1. On the Formulas tab, click the Name Manager
the Defined Names ribbon.
icon, located on
2. Highlight the name to be changed and then click the
button.
3. Type the new name (no spaces or special characters allowed) and press ENTER .
4.
Page 1
Microsoft Excel 2007
Database Functions & Scenarios
Database Functions in Excel
Database functions are great tools to analyze data by using easily-changed criteria. From
extracting information with formulas to filtering data, Excel gives you many useful tools. The
syntax for these functions are as follows:
=Dfunction(database range, field, criteria)
Dfunction
The function’s name
Database Range
All the cells in the database
Field
Refers to a particular column in the database
Criteria
Specifies the basis on which you want the
function select particular cells. A criteria
column must include a column heading.
What is an Excel database? It is a collection or block of cells that do not contain any empty rows
or columns. The data in that block of cells can be analyzed with specific Excel functions. The
block of cells is also called a datalist.
Page 2
Microsoft Excel 2007
Database Functions & Scenarios
=DSUM
This function sums the numbers in a column or database that meet a given criteria.
Prepare the datalist
1. If any of the data columns do not have a column heading, add those first.
2. Highlight all the cells in the datalist, INCLUDING the column headings (shortcut: place
the cursor on any cell in the datalist containing data and then press CTRL+SHIFT+* ).
3. In the Name Box, illustrated below, type a name for the datalist (see page 1 for
information on how to name a range) and press ENTER.
Prepare the function
4. Copy the column headings and paste them into a blank area of the worksheet or onto a
blank worksheet.
5. Place the cursor in the cell where the answer is to be displayed.
Page 3
Microsoft Excel 2007
Database Functions & Scenarios
Start the function
6. Click the Insert Function
icon, illustrated below.
7. Type DSUM and press ENTER twice.
8. In the Database field, type the name of the datalist that was created in step #3.
9. Place the cursor in the Field named “Field”, and then click the column heading of the
column containing the numbers to be totaled.
10. Place the cursor in the Criteria field, and then highlight the column headings that were
copied/pasted (step #2 above) and the cells directly below the column headings.
11.
12. Test the DSUM function:
a. Type a criteria word into one of the blank cells directly below one of the
copied/pasted headings (step #4 above) and pressing ENTER . In the cell
containing the DSUM function, the answer will be displayed.
Page 4
Microsoft Excel 2007
Database Functions & Scenarios
=DAVERAGE
This function averages all numbers in a column based on a given criteria. The steps to use this
function are the same as the ones for =DSUM, except for step #7. Use =AVERAGE instead.
=DCOUNT
This function counts the number of records that meet the specified criteria. It is possible to use
multiple criteria to more narrowly define the count. The steps to use this function are the same
as the ones for =DSUM, except for step #7. Use =COUNT instead.
=DMAX & =DMIN
The DMAX function returns the largest value in a list and DMIN returns the smallest value. The
steps to use this function are the same as the ones for =DSUM, except for step #7.
Use =DMAX or =DMIN instead.
Page 5
Microsoft Excel 2007
Database Functions & Scenarios
Scenarios
An Excel worksheet is a wonderful tool for “what if” analysis because one change results in
possible outcomes through many different calculations. A disadvantage of using the worksheet
to “play” with possible data changes is that it may be difficult to restore the original data.
Excel’s Scenario Manager is useful for this type of “what if” analysis.
1. On the Data tab, click the What-if Analysis
the Data Tools ribbon.
2. Click Scenario Manager.
icon, located on
3.
.
4. In the Scenario Name field, type a name for the new scenario. Make it descriptive since
there may be several scenarios created from the same data.
5. Click the Changing Cells field.
6. While pressing down the CTRL key, click each cell allowed to change in the scenario.
7.
8. Use each field to specify how the variable is to be changed.
9.
10. Repeat steps #3-#9 for each scenario.
11.
Page 6
Microsoft Excel 2007
Database Functions & Scenarios
Viewing a Scenario
1. On the Data tab, click the What-if Analysis
icon, located on
the Data Tools ribbon.
2. From the list of scenarios, click the one to be displayed.
3.
4.
Viewing a Scenario Summary
1. On the Data tab, click the What-if Analysis
the Data Tools ribbon.
2. Click the
3.
icon, located on
button and then specify what type of report is to be generated.
This will create the report as a separate worksheet tab at the bottom of the
screen.
Page 7
Microsoft Excel 2007
Database Functions & Scenarios
Lookup Tables
A lookup table compares a value to a list of values. When the value is found in the lookup table,
a corresponding data item is returned.
=VLOOKUP(Original_cell, Table_cells, Column_num)
Original_cell
Table_cells
Column_num
The cell containing the value to be compared to the list of values in the table
The ABSOLUTE cell range of the table
The number of the column (reading from left to right) containing the data to be displayed
Example #1 – (Using VLOOKUP to Display a Student’s Grade)
The VLOOKUP will compare the students’ average (column F) to the lookup table (C11:D15)
and then issue the letter grade associated with the average
1. Create a new workbook and enter the following data (only the data in cells A1:F7).
Page 8
Microsoft Excel 2007
Database Functions & Scenarios
2. In cells C11:D15, create the two-column lookup table:
a. In the left column, type the minimum score allowed for the associated letter
grade. They have to be sorted in ascending order!
b. In the right column, type the letter grade that is to be displayed.
3. In cell G1, type the label displayed in the previous illustration.
4. Place the cursor in cell G2.
5. Click the Insert Function
icon, illustrated below.
6. Type VLOOKUP and press ENTER twice.
7. Place the cursor in the Lookup_value field, and then click the cell containing the first
student’s average.
8. Place the cursor in the Table_array field, and then highlight all the cells in the lookup
table (C11:d15).
9. From the keyboard, press the function F4 key.
10. Place the cursor in the Col_index_num field and type a “2” which instructs the function
to look at the second column of the lookup table for the item to display in the cell.
11.
12. Copy the function for the other students in the list.
Page 9
Download