COVER PAGE CSC102B Excel TUTORIAL ©2003 and beyond, Lawrence Morales Excel Tutorial - Page 1 Intentionally blank for double-sided copies. Excel Tutorial - Page 2 TABLE OF CONTENTS COVER PAGE ................................................................................................................................................................. 1 TABLE OF CONTENTS ................................................................................................................................................. 3 BASIC EXCEL FACTS AND USAGE........................................................................................................................... 5 BASIC INTRODUCTIONS TO A SPREADSHEET ................................................................................................................... 5 ENTERING DATA............................................................................................................................................................. 6 EDITING CELL CONTENTS............................................................................................................................................... 8 Changing Cell Formats............................................................................................................................................. 8 Changing Row and Column Sizes ........................................................................................................................... 13 Changing Cell Contents.......................................................................................................................................... 14 WORKING WITH FORMULAS ......................................................................................................................................... 14 COPYING FORMULAS .................................................................................................................................................... 15 ABSOLUTE REFERENCES ............................................................................................................................................... 19 SORTING DATA ............................................................................................................................................................. 21 BASIC MATHEMATICS COMPUTATIONS ............................................................................................................ 29 BASIC MATHEMATICAL FUNCTIONS ............................................................................................................................. 29 Addition................................................................................................................................................................... 29 Subtraction.............................................................................................................................................................. 30 Multiplication.......................................................................................................................................................... 31 Division................................................................................................................................................................... 31 Powers and Exponents............................................................................................................................................ 32 The Natural Base, e................................................................................................................................................. 33 Square Roots ........................................................................................................................................................... 34 The Natural Logarithm ........................................................................................................................................... 35 The Value of π ......................................................................................................................................................... 35 Rounding................................................................................................................................................................. 35 Rounding Up and Rounding Down ......................................................................................................................... 36 BASIC STATISTICAL FUNCTIONS ................................................................................................................................... 37 Averages and Means ............................................................................................................................................... 37 Sums........................................................................................................................................................................ 37 Minimums................................................................................................................................................................ 38 Maximums............................................................................................................................................................... 38 The Range ............................................................................................................................................................... 38 DATABASES .................................................................................................................................................................. 39 BASIC INTRODUCTION TO DATABASES ......................................................................................................................... 39 THE DCOUNT COMMAND ........................................................................................................................................... 40 THE DAVERAGE, DSUM, DMIN, DMAX COMMANDS ............................................................................................ 44 SPECIAL EXCEL FUNCTIONS.................................................................................................................................. 46 THE COUNT COMMAND .............................................................................................................................................. 46 THE COUNTIF COMMAND ........................................................................................................................................... 47 THE RAND COMMAND ................................................................................................................................................. 49 THE RANDBETWEEN COMMAND .............................................................................................................................. 50 THE IF COMMAND ........................................................................................................................................................ 51 THE VLOOKUP COMMAND ......................................................................................................................................... 57 THE HLOOKUP COMMAND ......................................................................................................................................... 59 THE INDEX COMMAND................................................................................................................................................ 60 OPTIONAL: HOW I BUILT THE PHONE LOG FILE ........................................................................................................... 63 GRAPHING .................................................................................................................................................................... 64 BASIC GRAPHING ......................................................................................................................................................... 64 GRAPHING FUNCTIONS ................................................................................................................................................. 78 Excel Tutorial - Page 3 GRAPHING HISTOGRAMS .............................................................................................................................................. 83 Bins and Midpoints ................................................................................................................................................. 86 Frequency Command .............................................................................................................................................. 89 Formatting the Histogram ...................................................................................................................................... 90 TRENDLINES ................................................................................................................................................................ 98 THE LINEST COMMAND ............................................................................................................................................ 102 Excel Tutorial - Page 4 Basic Excel Facts and Usage Basic Introductions to a Spreadsheet A spreadsheet is a software tool that allows you to work with data (mainly numerical) in very complex and helpful ways. In MATH116 and MATH&148, Excel will be used extensively to complete the projects in each of the course. Hence, it is crucial that you have a basic understanding of how spreadsheets work. Here is a basic screen shot of Excel. Please take time to read the callouts to learn some basic spreadsheet vocabulary. Clicking on a tab on the Ribbon This region is called the brings up groups of commands Ribbon. related to each other. This is the formula bar where you enter and edit formulas. The Address Box tells you what cell is currently active. You can enter in a cell address to go to directly to a cell, or use it to give a cell a specific name. Each of these boxes is called a “Cell.” Cells contain, numbers, text, formulas, or even pictures. A cell’s address is given by the intersection of the column letter and the row number. This particular cell’s address is B3. When you click on or move to a cell, its border will become highlighted, as shown here. These tabs select Sheets that you can work in. The current sheet being worked in is in bold letters. This class will often use files with several sheets included so pay attention to whether or not these are labeled or named to indicate more than one sheet exists. Excel Tutorial - Page 5 A spreadsheet may be used to quickly process numerical data, like the simple sales tax sheet shown below: Or, they could be used to simulate complex random sampling situations for complicated and intricate mathematically based problems, such as those we will encounter in MATH116 and MATH&148. Entering Data Entering data into a spreadsheet is as simple as clicking once on a cell and entering the data. You can also use the arrow keys on your keyboard to navigate to a cell. The active cell will be highlighted and its address will appear in the Address Box. If you have not opened up Excel yet, please do so now by opening the file, Blank.xls. Practice moving around the cells if you are new to a spreadsheet. (In this tutorial, any text that is blue and underlined is a link to an existing file. To open the link, click on it. If that does not work, try to hold down the Ctrl button on your keyboard while you click once on a link.) The simplest kind of data to input is text and numbers. Practice Open Navigate to Cell A1 and type in the words “Tax Rate” followed by the Enter key. In Cell B1, type in the number .0865 (which corresponds to 8.65%). Continue to edit your worksheet until it looks like this… Excel Tutorial - Page 6 Your entry into cell B2 may not look like a percent when you entered in .0865. To covert a cell to percent form, choose the cell and the click on the percent button on the toolbar: In cells A4, A5, etc, enter in a series of numbers. If you want, you can just copy the numbers you see above. You will probably notice that the numbers you enter are not in dollar format. To format a group of cells in dollar form, move your mouse to the starting cell (A4 in this example) and hold the mouse button down while you drag to the last cell you want to format. It should look like this: You can then format all of the highlighted cells by clicking on the Dollar format button, shown below: Excel Tutorial - Page 7 Editing Cell Contents To edit or change the contents of a cell, navigate to that cell. You will notice that the Formula bar changes to reflect the contents of the active cell. To edit the contents of that cell, simply use your mouse button to click in side the Formula bar and edit it as you like. Try in now if you like…change the value of Cell A7, for example, from 8 to 3. Changing Cell Formats There are a variety of different formatting changes you can make to a cell. Here’s a quick rundown of important formatting tools. (Your tool bar may look a little different than the one shown here, but the buttons all do the same thing.) For more information, read on in this section: Change font size Change font and styles Change font color Change cell border Excel Tutorial - Page 8 Format as money Change cell alignment Format as percent Merge two or more cells. You can make text Bold, Italicized, or Underlined using the formatting buttons shown below: You can also center text within a cell, or align it to the right or left of a cell with these buttons: One handy feature of Excel allows you to merge two or more cells into one larger cell. This is helpful when you are formatting spreadsheet so that they look more professional. For example, in the sheet below, Cells A1, B1 and C1 have been merged into one large cell: To merge cells, use the mouse to click and drag all the cells you want to merge. Then click the Merge button, as shown below: Excel Tutorial - Page 9 To change the font or size of a cell’s contents, use the font formatting tools, shown below: You can also change the color of the text or data inside a cell. Simply use the Font Color button, as shown below: Another nice feature is the ability to add solid borders to cells so that when the sheet is printed, the borders show up. (By default, the grey cell borders you see while working in a spreadsheet do not print.) Borders can be added using the border tool: Excel Tutorial - Page 10 As you can see, there are a variety of border options available. Experiment with them to see how they work…they are pretty straightforward. Finally, you will often want to format each cell in terms of decimal places, dollar signs, date formats, percentage format, etc. To format a cell in a particular way, click on the cell(s) you want to change and then RIGHT click on the cell with your mouse. Choose the “Format Cells…” command and you’ll get a box like this. Excel Tutorial - Page 11 The “Number” tab will allow you to specify what kind of data is in that cell or cells. For example, if you want a number, click on “Number” in the “Category” list: Excel Tutorial - Page 12 The new window will allow you to specify how many decimal places to display and change other formats. (This screen will not round the data, only change what is seen on the screen!). The other tabs will allow you to change the fonts, borders, etc. However, it’s usually best to keep things simple, as this generally means it’s easier to read. Changing Row and Column Sizes Changing the size of rows or columns is simple. Move your mouse to the vertical bars that separate each column (or row) until the arrow cursor changes and looks like this: Then drag your mouse until the column is as large or small as you like: Excel Tutorial - Page 13 Shortcut: If you want to make a column or row automatically size itself to fit its contents, click once on the row or column label (the numbers 1,2,3,… or the letters A, B, C,…) and then DOUBLE−CLICK on the vertical bar directly to the right or below the column or row you want to resize. Changing Cell Contents There are a variety of different Working with Formulas Working with simple formulas in Excel is as easy as using an “=” sign and typing in the formula correctly. One of the most common calculations is to take numbers in two or more different cells and compute with them. Practice Open the file called Formulas.xls. Make sure you are on the Sheet called “Copy Down” before proceeding. You will see two columns of numbers. In Cell C2, type in the word “Sum.” We are going to add the two numbers in each row and put the result in Column C. In Cell C3 type the following: =A3+B3 followed by the Enter key. You should see the number 13 appear in Cell C3. Note that Cell C3 tell Excel to take whatever is in Cell A3 and add it to whatever is in Cell B3. This is helpful because if were to change the contents of either A3 or B3, the result would automatically change in C3. Try it…change A3 and/or B3 to make sure it works. Excel Tutorial - Page 14 Practice Let’s continue to modify the file called Formulas.xls. In Cell D2, type the word “Product”. In Cell D3, type the following formula: =A3*B3 followed by the Enter key. You should see the number 30 appear in D3. This is the product of the first two numbers on our list. Copying Formulas In the previous Practice problems, we’ve managed to compute the sum and product of two numbers. If we want to duplicate that set of calculations for all of the rows present, we certainly do not want to have to type formulas into every cell. Instead, we will copy or duplicate the formulas down the columns in one short set of steps. Example Let’s continue to modify the file called Formulas.xls. At this point, it should look like this: We are going to copy the formula in Cell C3 all the way down to the end of the list of numbers we have. To do this first click once in Cell C3 and hold the mouse down while you carefully drag to the end of the list. Your screen should look something like this: Excel Tutorial - Page 15 Now, while you hold the Ctrl button down on the keyboard, hit the D key. This is called a Ctrl−D command. When you do so, the Cells in Column C should fill themselves in as below: Now here is the best part! Click on any of these new cells, such as C4 and look at the formula bar. You will notice that the original formula you entered into C3 has been copied but it has been automatically altered to reflect the fact that you are now adding numbers in Row 4. Excel is smart enough to adjust these new formulas for you so that you get the results you were actually looking to get. The original references to A3 and B3 that we entered into Cells C3 and D3 are called relative references. This means that should we copy the formulas in these cells to other cells, Excel will assume that we want to copy the formulas so that they adjust, relative to the original formula. Excel Tutorial - Page 16 Practice Copy the formula in Cell D3 down to include all the numbers with rows in them. Make sure each new entry really is the product of the numbers in Columns A and B. Example We can also copy a cell’s formula to the right with the Ctrl−R (Control Right) command. In the Sheet called “Copy Right” in the file Formulas.xls, you will notice numbers in rows, rather than in columns. Please examine the formulas in Cells B4 and B5. Now, click on Cell B4 and then hold the mouse button down while you drag over to Cell F4. Use the keyboard to type a Ctrl−R command (This means hold the Ctrl button down while you type the letter R.) The formulas should be copied and the calculations down for you so that the file looks like this: Practice Copy the formula in Cell B5 to the right to multiply all the column pairs of numbers. The Copy Handle There is one other way to copy formulas to the right, left, down, or up from a cell that already has a formula in it. In the Sheet called “Copy Handle” in the file Formulas.xls, you will see a set up as follows: Click on Cell E4 to see the formula =E3+5. When you click on the cell, you should notice a small, square handle in the lower right corner of the cell: Excel Tutorial - Page 17 The Copy Handle I’ll call this the “Copy Handle.” If you click on this handle and hold the mouse button down while you drag over to cell I4, Excel will copy the formula of E4 across the row. Try it! You can also click on E4 and drag the Copy Handle down Column E. Try it! Finally, you can drag the Copy Handle in Cell E3 to the left and it will copy the formula to the left. I’ve doe this and here is what my sheet looks like now: You can now click on any cell with a number/formula in it and drag right, left, or down to fill in formulas. As a matter of fact, you can do it very efficiently. For example, select the range of cells A4 to I4 as shown below: Note that this entire range has one Copy Handle associated with it. Grab this handle and drag down to Cell I9 (or thereabouts) and watch all of the rows fill in nicely: Excel Tutorial - Page 18 This provides a quick and easy way to copy your relative formulas all over a sheet and not have to type each on in by hand. Absolute References Sometimes, you don’t want your formulas copied in a relative way. There may be a particular cell that you always want to be part of a formula. Excel uses absolute references to accomplish this and it uses the $ sign inside a Cell address to make the address absolute. For example, if you always wanted Cell A2 to be used in a calculation, you would need to type in $A$2 to tell Excel this is an absolute reference. Let’s see how this would work: Example Open the Sheet called “Shipping” in the file Formulas.xls. The goal of this example is to add the Shipping Fee of $8.95 in Cell A2 to every relevant row of the “Total with Shipping” Column. To do this, we enter the following into Cell B8: =A8+$A$2 and then copy this formula down using Ctrl−D. Here is what the results look like: Excel Tutorial - Page 19 Note that we can change the shipping amount in A2 and all the cells in Column B will update. Example Edit the sheet “Shipping” so that in Column C, the “Total with S&H” of each cell adds the “Order Amount” to the Shipping Fee in A2 and the Handling Fee in Cell A5. Try to use Copy Down for practice. Answer: Excel Tutorial - Page 20 There are other variations on using absolute references. For example, you may want a cell to compute with a particular row but allow the column to be relative (and therefore change) or vice versa. Here are the three possibilities for absolute or partially absolute references. Example Type Comment $A$2 True absolute reference Forces computation with Cell A2 $A2 Partial absolute reference Forces computation with Column A but allows the row number to change relative to the formula. A$2 Partial absolute reference Forces computation with Row2 but allows the Column to change relative to the formula. Note: If you are editing a formula, using the F4 key will cycle you through different kinds of absolute references. Just make sure the reference you want to change has the edit cursor immediately to the left of the reference in the Formula Bar. Sorting Data Sorting data sometimes makes it easier to see what is going on. Open the file Employees.xls to see a series of Sheets with data in them. The Sheet called “Employees” is a simple list of Employee ID numbers. To sort these in ascending or descending order, we use the Sort & Filter button on the toolbar. First, click on Column A so that the entire column is selected. (Click on the box with the A at the top of the column.) Your column should look like this: Excel Tutorial - Page 21 Now click on the Sort & Filter button and then choose and the employee number will be sorted in ascending order. Clicking on the Sort Down button will sort them in descending order. Usually, however, you will want to sort more complicated data. Select the Sheet called “Sales Records” to see data on the employees’ sales records and their time employed at the company. Excel Tutorial - Page 22 Example We want to sort these records by their Employee number once again, but if we simply sort what is in Column A, then the records will not match the data that is Columns B and C. To make sure that all the data is sorted correctly, we first need to select all the rows to be sorted. Move your mouse to the left side of the screen until the arrow is over the “1” in the box that identifies Row 1. If you do this correctly, the normal cursor arrow will turn into a heavier arrow pointed to the right that looks like this: Click once on the mouse button and drag it down to Row 22, and then release the mouse button. Your screen should look like this: All rows should be highlighted. Now you can use the Sort Up or Sort Down Button to sort by Employee number. Note: Excel will automatically sort the data according the column on the very left of whatever is highlighted. You can also shift to the Data portion of the Ribbon and use the Sort buttons there as well: Excel Tutorial - Page 23 If you want to sort by Sales amount, you’ll need to use the Sort command in the Data tab of the Ribbon: Example Let’s sort the Employee data now by Sales. Once again, use the row labels to highlight Rows 1 to 22. Click on the Sort button in the Data group (see picture above) and you’ll get this box: If the “My data has headers” box is checked, then Excel looks at the first row of the data that is highlighted and treats that as the one that has headers, or descriptors in it. When it sorts the data, it will leave the header row at the top (as you would want) and sorts everything below the header row. This box allows you to specify what to sort by first. The default is the left−most column, but we can select Sales instead, as below: Excel Tutorial - Page 24 Doing this and clicking OK will sort by Sales from smallest to largest values: Again, it is vital that all rows and columns be selected so that when the data is sorted, the Employee number is properly matched up with that person’s sales total and years on the job. Example Let’s sort by Years on the job first (ascending), and then by sales (descending). After selecting all rows, we choose the Sort button and then configure our Sort box as follows. First, select years on the job as the first sorting criterion: Excel Tutorial - Page 25 Then, we add a level of sorting so we can also sort by Sales. To do this, click the “Add Level” button: You can then Choose Sales from the first box and Largest to Smallest from the last box: Excel Tutorial - Page 26 When we click OK, we get the following: This allows us a view of the data that is perhaps very helpful if we are a manager trying to determine who the most effective salespeople are. Practice Open the file ClassData.xls and sort all records by Student ID (ascending). Excel Tutorial - Page 27 Answer: The first few rows should look like this: (check all the way across the row to make sure you have it sorted correctly.) Practice Open the file ClassData.xls and sort all records by Exam 2 (descending). Answer: The first few rows should look like this: (check all the way across the row to make sure you have it sorted correctly.) Practice Open the file ClassData.xls and sort all records by Exam 1 (descending) THEN Exam 2 (descending) THEN by Exam 3 (descending). Answer: The first few rows should look like this: (check all the way across the row to make sure you have it sorted correctly.) Excel Tutorial - Page 28 Basic Mathematics Computations There are several special mathematical computations you will need to be able to do in Excel. This part of the tutorial covers many of these. The first thing to be aware of when doing any computations in Excel is that you will usually need to start the contents of a cell with the “=” sign in order for Excel to recognize the formula computations. Basic Mathematical Functions Addition To add two or more numbers, use the + symbol, as you would normally. Example To add 5+3+2 type the following into a cell =5+3+2 When you hit the Enter key, the cell will change to a 10. If you want to add numbers that are located in different cells, you need to type in the cell addresses for each number to be added to the result. Example Suppose you wanted to add the values that are in cells A1, A5, and B6 (see below), and you wanted to place the result in cell C1. Excel Tutorial - Page 29 Type the formula =A1+A5+B6 in this cell In cell C1, type the following: =A1+A5+B6 When you hit the Enter key, cell C1 will display 24. There is a nice shortcut to typing cell references that can save time. Instead of typing the cell reference, use the mouse to point and click at the cell you want entered into the equation. In this example, you can do the following: Type = Use the mouse to click once on cell A1 Type + Use the mouse to click once on cell A5 Type + Use the mouse to click once on cell B6 Hit the Enter key Practice Open the file called BasicMath.xls and use it to add cells A8, B2, and B7. Try to use both methods described above. Answer: 17 Subtraction To subtract numbers, use the − symbol, as you probably suspected. Example To compute 20+3−5−8, you would type: =20+3−5−8 The result will be 10, as it should be. Practice Open the file called BasicMath.xls and use it to compute the result of 56+A4−13−B3 Excel Tutorial - Page 30 Answer: 46. Multiplication To multiply numbers, use the * symbol, which is Shift−8 on the keyboard. Example To compute 2 × 3 × 4 , you would type: =2*3*4 followed by the Enter key. Practice Open the file called BasicMath.xls and use it to compute the result of 3*A4*B12 Answer: 210 Example If you want to use the distributive property of multiplication, you will need to use parentheses. To compute 5(3 + 2 − 8 + 7) , you would type: =5*(3+2−8+7) Notice that you need the * between the 5 and the left parenthesis. Excel will display an error message without it. Practice Open the file called BasicMath.xls and use it to compute the result of 4(6−A10+B5+3). Answer: 40 Division To divide two numbers, use the / symbol on the keyboard. Example 32 To divide , which is the same as 32 ÷ 8 , type: 8 =32/8 followed by the Enter key. Example You need to be very careful with division and the order of operations. For example, if you 3+8 want to compute , you must tell Excel that the 3+8 are to be added before being 4 divided by 4. Hence, to compute this, you would type: Excel Tutorial - Page 31 =(3+8)/4 followed by the Enter key. The result will be 2.75, which is correct. Note that if you were to type the following; =3+8/4 8 then Excel would actually compute 3 + , which is 5, a totally different (and wrong) result. 4 Practice 5+ 6+ 7 +3+ 4+ 6+ 7 . 7 Answer: Approximately 5.428571 Compute Practice Open the file called BasicMath.xls and use it to compute the result of A3 + A2 + B5 + B9 12 Answer: 2.25 Powers and Exponents If you want to raise numbers to powers, then you need to use the ^ symbol, which is Shift−6 on the keyboard. If you familiar with a TI graphing calculator, this symbol is the same symbol you used to compute with powers. Example To compute 2 4 , you would type: =2^4 to get a result of 16 Example To compute (2 + 5) , you would type: 3 =(2+5)^3 to get a result of 343. Example To compute 4(2 + 3) ( 2 +1) , you would type: =4*(2+3)^(2+1) to get a result of 500. Note that if the power is complicated, you may need to use parentheses to make sure the proper exponent is applied. Practice Compute 5 4 . Answer: 625 Excel Tutorial - Page 32 Practice Compute 2.35 3 . Answer: 12.97788 Practice Compute 7 + 2(4 − 3 − 5) Answer: −121 3 Practice Open the file called BasicMath.xls and use it to compute the result of 5(B1−A3)5 Answer: -15625 The Natural Base, e One of the most important bases we apply exponents to is e, the natural base. The value of e is about 2.72, but Excel knows its exact value, provided you use the EXP() command. If you just use the letter “e” in the formula, Excel will not recognize it as the natural base. Example To compute e1 , which is of course just e, you would type: =EXP(1) to get the value of e to however many decimal places Excel is set to display in that cell. Example To compute e 5 , you would type: =EXP(5) to get a value of 148.4132. Example To compute e (1+ 2.35 ) , you would type: =EXP(1+2.35) to get a value of 28.50273. Note that you need parentheses around the exponent part. Excel Tutorial - Page 33 Practice Compute e 5.45 − 3.26 . Don’t forget to use parentheses around the exponent part. Answer: 8.935213. Practice 1 ( 3− 7 ) Compute e 2 . Don’t forget to use parentheses around the exponent part. Answer: 0.135335. If you did not get this, check your entry to make sure it looks like this: =EXP((1/2)*(3-7)) Make sure you recognize how and why each of the set of parentheses is being used. Square Roots The most common root you will need in this course is the square root. To compute a square root, you can do one of two things: (1) You can raise the base to the power of ½. Recall that taking a square root is the same as raising a number to the power of ½. (2) You can use the SQRT() command. Example To compute 18 , you can type one of the following: =18^(1/2) OR =SQRT(18) Notice that in the fist case, parentheses are needed around the ½. This is important! Also, in the second case, parentheses are needed around whatever is inside the square root symbol. Example To compute 5 + 20 , you can type one of the following: =(5+20)^(1/2) OR =SQRT(5+20) Either one gives you a result of 5. Practice Compute the value of 12 + 36 − 15 Answer: 5.744563 Practice Compute the value of Answer: 15.75608 Excel Tutorial - Page 34 38 + 2 5 + 18 The Natural Logarithm This course will require that you do limited computations with logarithms. The logarithm we will use is the natural logarithm, which is symbolized by ln. Excel can compute these easily using the LN command. Example To compute the value of ln(10), you would type: =LN(10) to get a value of 2.302585. Note once again that parentheses are needed. Whatever you are taking the logarithm of needs to be in parentheses. Example To compute ln(5 − 8 + 2 × 9) , you would type: =ln(5−8+2*9) to get a value of 2.70805. Practice Compute the value of ln(44.5) Answer: 3.795489. Practice Open the file called BasicMath.xls and use it to compute the result of 5−ln(B5+A3) Answer: 2.227411. The Value of π The value of π can be easily computed in Excel. Simply type =PI() into a cell or any part of a formula and the value of π will be invoked. Note that the parentheses are necessary. Rounding When you want to round numbers, the ROUND command is used. The syntax is: =ROUND(value, rounding_parameter) where value is the number to be rounding, and rounding_parameter is the number of places to round to. Example To round cell A5 to the nearest hundredth (2 decimal places to the right of the decimal point), you would enter: =ROUND(A5,2) Excel Tutorial - Page 35 Example To round cell A5 to the nearest tenth (1 decimal place to the right of the decimal point), you would enter: =ROUND(A5,1) Example To round cell B10 to the nearest integer (0 places to the right of the decimal point), you would enter: =ROUND(B10,0) Example To round cell C1 to the nearest ones place, you would enter: =ROUND(C1,−1) Note that the rounding parameter is −1, indicating you are rounding to one place to the LEFT of the decimal place. Practice The file SalesTax.xls has a random list of sales prices. In the column titled “Sales Tax,” compute the sales tax on each item, using the ROUND command to round the tax amount to the nearest penny. Use absolute references to insure that you use the constant tax rate in Cell B1. Then fill in the “Total Due” column, which is the sum of the Price and Sales Tax. When you are done, you should be able to change the value of the tax rate in Cell B1 and see all your other values change accordingly. Note that the ROUND command rounds to the nearest place value. That is, it may round up or round down, depending on the value. If you want to strictly round up the next place or down to the previous place, then the following commands are used. Rounding Up and Rounding Down To round up, we use the ROUNDUP command, which has a similar syntax to ROUND. The difference is that it will round a value UP. To round down, we use the ROUNDDOWN command, which has a similar syntax to ROUND. The difference is that it will round a value DOWN Example To round the value 345.8768 UP to the thousandths place (3 decimal places), we would enter: =ROUNDUP(345.8768,3) to get a value of 345.877. This is also what you would get if you use the ROUND command. However…. Excel Tutorial - Page 36 Example To round the value 345.8768 DOWN to the thousandths place (3 decimal places), we would enter: =ROUNDDOWN(345.8768,3) to get a value of 345.876. This is not what you would get if you use the ROUND command since this command does not round to the nearest or up, but down to the previous place specified. Basic Statistical Functions Averages and Means To find the average, or the mean, of a group of numbers, we use the AVERAGE command. The syntax is: =AVERAGE(cell_range) Example To find the average of the numbers in cells A1 to A50, we would enter: =AVERAGE(A1:A50) This is pretty much straightforward. If you have numbers in more than one column, like from Cell A1 to Cell C20, then you would type: =AVERAGE(A1:C20) Practice Open the file SalesTax.xls and find the average of the Prices listed in Column A. Place your value in Cell A20. Answer: $16.52 Sums To find the sum of a list of numbers, we use the SUM command: =SUM(cell_range) Example To find the sum of the numbers in the block of data from Cell B20 to Cell T55, we would type: =SUM(B20:T55) Practice Open the file SalesTax.xls and find the sum of the Prices listed in Column A. Place your value in Cell A21. Answer: $264.25 Excel Tutorial - Page 37 Minimums To find the minimum number in a list of a block of cells, we use the MIN command: =MIN(cell-_range) Example To find the sum of the numbers in the block of data from Cell B20 to Cell T55, we would type: =MIN(B20:T55) Practice Open the file GPA.xls and find the minimum GPA listed. Answer: 0.53 Maximums To find the maximum number in a list of a block of cells, we use the MAX command: =MAX(cell_range) Example To find the sum of the numbers in the block of data from Cell B20 to Cell T55, we would type: =MAX(B20:T55) Practice Open the file GPA.xls and find the maximum GPA listed. Answer: 4.0 The Range The range of a set of numbers is simply the maximum in the list minus the minimum in the list. There are two ways to compute the range, therefore. Either (a) compute the MIN and MAX separately and then subtract them in a third cell. Or (b) use one command to do it in one cell using the a command like =MAX(cell_range)−MIN(cell_range). Just make sure the cell ranges used in each of the MIN and MAX command are the same. Excel Tutorial - Page 38 Databases Basic Introduction to Databases A database is a large collection of data and records. For example, open the file Chrysler.xls to see a database that represents the cars sold at a local Chrysler Dealership in the recent past. There are literally hundreds of records. Each row represents a different record. In this case, each record represents one individual sale of a car. Each record in a database is made up of several fields. The fields are the different parts of the record. In Chrysler.xls, the fields are Car Number, Style, Color, Sale Price, SalesPerson. Each of these fields has different kinds of values that are possible. For example, the Sale Price field must take on a number ($) while the Color field takes on text values (such as Red, Blue, etc.) These are the fields These are the records. Now suppose you wanted to ask questions like: “How many Red PT cruisers have we sold?” or “How many cars over $25,000 did Juan sell?” or “How many Concordes and Voyagers did we sell between $20,000 and $23,000?” Trying to do this would take a lot of time and hassle without special commands like DCOUNT. When using database commands like these, we need to give the commands specific criteria with which to work. Hence the first thing to do when using these commands is to duplicate the Field headings above or to the side of the actual data so that we can enter specific criteria. For example, we can alter Chrysler.xls as follows: Insert 7 new blank lines above the data. (Select Rows 1 to 7 by clicking on the Row 1 label and drag down to Row 7, then choose Insert→Rows from the Menus.) In cell A1, we will type “CRITERIA.” In cells A2 to E2, we will copy the original Field headings. Our modified worksheet will look like this: Excel Tutorial - Page 39 We will call this the Criteria Area. We will use cells A3 to E7 to fill in specific criteria. Usually 5 or six lines is enough, but if we need more, we can always insert new blank lines. With the Criteria Area now available we can proceed. The DCOUNT Command The DCOUNT command simply counts the number of records in a database that meet stated criteria. We enter the criteria into the Criteria Area and then run the DCOUNT command. This command uses the syntax: = DCOUNT(database,field,criteria) where database is the range of cells where the database is located, field is unused, and criteria is the range of cells where you specify what criteria to match and therefore which records to count. Example Let’s count the number of Red PT Cruisers sold at this dealership. Using Chrysler.xls, we will modify the Criteria Area so the first line has Red in the Color column and PT Cruiser in the Style column. It is crucial that we enter the text in without any spelling errors, including any spaces that are needed. This is how our file should look…try it yourself as we move along: Let’s use the Function Wizard to invoke the DCOUNT command since it’s easier than using the syntax. Excel Tutorial - Page 40 First, click on a blank available cell where Excel can report the number of Red PT Cruisers. Make sure you pick a cell that is not in the Criteria Area or part of the database. Let’s label Cell G2 as “DCOUNT” first and then use Cell H2 as the cell where we will return DCOUNT results. Click on Cell H2. We now use the DCOUNT command to count the number of Red PT Cruisers in the database. The format for DCOUNT is, as we saw above: = DCOUNT(database,field,criteria) In Cell H2, we enter the following command: The range A7:E537 is our database. Notice it includes row 7 which has the field names of our database. Also notice that the field parameter is blank. We don’t need it here. Finally, the range A2:E3 is the criteria range and it includes the row with the field headers and the row where specify the two criteria. When you use the DCOUNT command, the row with the field headers MUST be included in BOTH the database range AND the criteria range. Make sure that the “Criteria” box does not include any of the empty rows in the Criteria Area….if it does, it will count all 350 cars in the database. Example Let’s count the number of PT Cruisers sold at this dealership that are either Red or Black. To do this, we need to add another line in our Criteria Area as follows: When there are two or more rows filled out in the Criteria Area, DCOUNT will look for records that match ANY of the criteria and then add them all up. That is, Excel will look for any Red PT Cruisers OR any Black PT Cruisers. Because we changed the criteria, we also need to change the formula in Cell H2 to make sure it is updated. We could run the DCOUNT Function Wizard all over again, but here’s a nice shortcut that you can use any time you want to edit a function. Excel Tutorial - Page 41 Click once on Cell H2. Then hit the F2 key on the top row of the keyboard. When you do, your screen should look like this: Drag this handle to change the active Criteria. This is the Criteria range, highlighted in green This is the Database cell range highlighted in blue Notice two great things happen. First, the formula in H2 is displayed with colored fonts. The colors correspond to the colored boxes that are now outlined in blue and green. The database range is outlined in blue and the Criteria Area is outlined in green. If we want to include Row 4 in the Criteria Range, we can either edit A2:E3 so that it reads A2:E4, or we can simply point on the little square handle on the lower right corner of the green box (also the lower right corner of Cell E3 if you can’t see the color) and drag it until it expands to E4. When you do so, the screen will look like this: Note that the formula and colored boxes stay synchronized. Very cool!. Now hit the Enter key and the formula and Cell H2 will be updated. There are 17 PT cruisers sold that were either Red or Black. Practice How many Blue 300M’s were sold? Answer: 3 Practice How many Voyagers did Juan sell? What about Maria? Answer: 12 and 8 Excel Tutorial - Page 42 Practice How many Red Concordes did Bartoloa sell? Answer: 2 Practice How many PT Cruisers or Crossfires were sold? Answer: 118 Practice How many PT Cruisers or Crossfires were sold by Elias? Answer: 23 Practice Challenge How many PT Cruisers or Crossfires were sold by Elias or Juan? Answer: 43 (Hint: You need four lines filled in your Criteria Area!) Example Now, what if we want to count the number of PT Cruisers sold for under $22,000? Our Criteria Area and results would look as follows: Example How many 300M’s were sold for $25,000 or more by Celia? Our Criteria Area and results would look as follows: Example How many Pacifica’s were sold for between $18,000 and $22,000? This is a different question! We want to count all cars that meet both the >18000 AND <22000 criteria so we can’t use two different rows in the Criteria Area. (That would count each inequality separately and then add them, which is not what we want.) Both of the Price criteria have to be in one row. To accomplish this, we need to insert another column to the Criteria Area and label it “Sale Price.” We’ll use Column F and enter our criteria, like below. If we make sure the DCOUNT formula in Cell H2 includes the new Column, our results will be accurate: Excel Tutorial - Page 43 There were 14 Pacifica’s sold for between $18,000 and $22000. Practice How many Sebring’s were sold for more than $20,900? Answer: 19 Practice How many Town&Country’s were sold for less than $25,000? Answer: 26 Practice How many Black 300M’s were sold for more than $23,000? Answer: 6 Practice How many Voyagers were sold for between $21,000 and $23,000? Answer: 11 Practice How many Sebring’s or PT Cruisers were sold for between $15,000 and $18,000? Answer: 9 The DAVERAGE, DSUM, DMIN, DMAX Commands If you have a database and you want to find the averages, sums, minimum or maximum values subject to given criteria, these commands are the ones to use. They all work very similar to each other, so we’ll only cover DAVERAGE here. You can explore the rest on your own. DAVERAGE will find the average of some field in a database subject to your criteria. Practice What is the average price of all PT Cruisers sold in Chrysler.xls? We change Cell G2 to say “DAVERAGE” and use Cell H2 to compute this average. Make sure your Criteria Area looks like this: Excel Tutorial - Page 44 The command is as follows: The basic command structure is: =DAVERAGE(database,field, criteria) Now, the field criteria IS needed. We specify D7 as the field because that is the field header for the Sale Price data. Practice What is the average price of all of the M300’s sold by either Maria or Celia? Answer: $23,861.78 Excel Tutorial - Page 45 Special Excel Functions The COUNT command There are times when you have a long list of data and you want to quickly count how many items are in the list. The COUNT() command does this quickly. Open the file Count.xls to see a sheet full of numbers. Note that some of the cells are empty so that the columns do not necessarily have the same number of entries in them. The syntax for the COUNT command is: =COUNT(cell_range) The COUNT command counts the number of cells in a given range (specified by the cell range) that contain numbers within them. Example If you wanted to count the number of cells with numbers in the Red column, you would type in Cell A22: =COUNT(A1:A21) to get 20 for a result. Note that even though cell A1 is included in the range of cells to be considered, it is not counted because cell A1 does not have a number inside of it. Example If you wanted to count the number of cells with numbers in the Blue column, you would type in Cell B22: =COUNT(B2:B21) to get 17 as a result. Note that I did not include cell B1 in the cell range since I knew it would not be counted anyway. Example If you wanted to count the number of cells with numbers in BOTH the Grey and Black columns, you would type: =COUNT(H1:I21) to get 37 as a result. The range you use can include more than one column. Excel Tutorial - Page 46 Practice Open the file called Count.xls and use the COUNT command to count the number of cells in the Pink column with numbers in it. Answer: 18 Practice Open the file called Count.xls and use the COUNT command to count the number of cells in the Green and Brown columns with numbers in them. Answer: 18 Practice Open the file called Count.xls and use the COUNT command to count the number of cells in ALL of the colored columns. Answer: 164 The COUNTIF command Sometimes, simply counting is too general. There are times you want to count the number of items that meet specific criteria. The COUNTIF command will do this for us. The syntax for the command is: =COUNTIF(range, criterion) where the range specifies which cells to count and the criterion details what to look for. For example, the MachineJams.xls has a list of data a company has been recording for several months. The copy machine they lease has been jamming regularly, but the company they lease the machine from says nothing should be wrong with it, since it’s new. So, the company has recorded the number of times it jams per day to document their experience in case they need to insist that it be replaced. Each row represents a different day. What we want to do is count the number of days in which certain criteria are met. Excel Tutorial - Page 47 Example Suppose you want to count the number of days during the first 14 days in which there were more than 10 jams per day. (It is possible to count these with your naked eye, but we will practice using the COUNTIF.) You would type the following: =COUNTIF(B2:B15, “>10”) to get a result of 7. Note that the criteria should be in quotes. (It’s an odd rule, but it exists nonetheless.) Example Suppose you want to count the number of days during the first 20 days in which there less than or equal to 6 jams per day. You would type: =COUNTIF(B2:B21,"<=6") to get a result of 6. Note that ≤ is typed as <= in Excel. Example Suppose you consider the data for ALL 156 days they recorded the jams and you want to know how many of those days there were more than 8 jams per day. You would type: =COUNTIF(B2:B157,">8") to get a result of 104. Practice Find the number of days within the first 30 days in which there were 10 or fewer jams. Answer: 16 Practice Find the number of days within the days 20 to 90 (inclusive, meaning you include days 20 and 90) in which there were more than 15 jams. Answer: 18 Practice Find the number of days within the entire set of days in which the machine jammed exactly 20 times. Answer: 12 The COUNTIF command can also count cells in which specific text appears. For example, the attendant on duty is recorded in the third column of the file Count.xls. We can ask how often any of those people were on duty. Excel Tutorial - Page 48 Example To find the number of times that Hector was the attendant during the first 60 days, we would type: =COUNTIF(C2:C61,"=Hector") to get a result of 14. Practice Find the number of times that each of Jane, Bob, and Mary are the attendants from Day 1 through (and including) Day 100. Answer: Jane = 28; Bob = 20; Mary = 29 The RAND command Sometimes it is helpful to have Excel generate random numbers for you. To generate a random number between 0 and 1, we use the RAND command. Example To generate a random number between 0 and 1 in a cell, simply type: =RAND() Note that you need the two parentheses after RAND with nothing in them. Weird, but necessary. This command will continually change the number in that cell every time you do a new computation, enter data into a new cell, or press the F9 key. Try it....press F9 over and over and you’ll see the number change. If you need several random numbers in a column or row, simply copy right or copy down from a cell that has the RAND command inside of it. This will generate as many random numbers as you may need. Sometimes, you don’t want the random numbers to constantly change. One way to fix their value is to select all the cells you want to fix and then copy all of data using CRTL-C on the keyboard. Then click on the first cell in the range (upper left corner if you’ve selected a block of cells) and then right click. If you choose “Paste Special…” you will see the following box appear: Excel Tutorial - Page 49 You can also use the Paste button on the Ribbon to bring up the same box. If you choose Values (in the box) or Paste Values (from the menu), then Excel will paste in the current random values as fixed numbers. Note that when you do this, all your randomization in those cells will go away for good. The RANDBETWEEN command While the RAND command returns numbers between 0 and 1, there are times when you want to generate numbers outside that range. The RANDBETWEEN command will generate random integers between any two integers that you specify. The syntax for the command is: =RANDBETWEEN(bottom,top) where bottom is the smallest possible integer you want returned and top is the largest. Excel Tutorial - Page 50 Example Suppose you want to generate a random number between 1 and 100. Then you type: =RANDBETWEEN(1,100) to get a random number. Note that like the RAND command, cells with this command in them will change with F9 or other entry into your spreadsheet. The IF command The IF command is one of the most useful tools you will encounter in Excel. It allows you to ask questions about data and then, based on the answers to those questions, return results that are desired. We will start with basic usage of the IF command and then expand it just a bit. The syntax for the IF command is: =IF(condition, yes result, no result) where condition is the question you ask, yes result is the value, result, or cell that is returned if the answer to the question/condition is yes, and no result is the value, result, or cell that is returned if the answer to the question is no. Let’s start with some simple examples. Example Let’s go back to our copy machine example. In the file JamsPart2.xls, a new column has been added to indicate whether or not the number of daily jams is acceptable or not. The new file looks like this: In the “Acceptable?” column, we will use the IF command to indicate whether or not the number of jams is acceptable. We will arbitrarily decide for this example that if the number of jams is less than 8, then that is acceptable, otherwise it is not. If it is acceptable, we will place a 1 in that row, if not then we will place a 0 in that row. Here is how you would issue that command in cell D2: Excel Tutorial - Page 51 =IF(B2<8,1,0) Once you have the formula entered into cell D2, you can use the Copy−Down command (Ctrl−D) so that it applies to all the rows on the sheet. When you do so, you get the following: To save space, only the first few rows are shown. Example In the previous example, having 1’s and 0’s may not mean much to someone unfamiliar with the sheet, so let’s put “Yes” or “No” in the Column D instead. When you want to return text as a result rather than a number, then you put the text in quotes. Here’s how you would do it in this example: =IF(B2<8,"Yes","No") This produces a very similar result: Excel Tutorial - Page 52 Example There may be times when you want either of the Yes or No returns to be a blank cell with no text or numbers. To do this, you enter two quotation marks next to each other (“”). For example, let’s say we want a “Yes” to appear if the number of jams is below 8, but a blank cell otherwise. The command would be: =IF(B2<8,"Yes","") This gives the following: Excel Tutorial - Page 53 Practice In the acceptable column, use the IF() command to place the works “Oh Yeah” if the number of jams is 10 or less and the words “No Way” otherwise: Answer: Example Sometimes you want to return a cell value already in existence rather than a fixed value as in the examples above. This is easy. Let’s say you have a tax system where anyone making less than $35,000 per year pays 20% in taxes. Anyone making $35,000 or more pays 22% in taxes. (The U.S. system is a little different, with a staggered tax system, but this is a simple example.) What we want to do is calculate how much tax a person pays given their income and we want to do it for many individuals. The file Taxes.xls has data that looks like this: Excel Tutorial - Page 54 In the “Total Taxes” column, we want to calculate how much tax each income would pay. In this example, we need to test whether or not the income is above $35,000. If it is, then we multiply that amount by 0.22. Otherwise, we multiply it by 0.20. Here is what the command in Cell B2 would look like. Make sure it seems reasonable to you: =IF(A2<35000,A2*0.2,A2*0.22) This will return the following results: Note that the values that are returned can include cell references and numbers, as well as any computations that are needed. Practice Use the Taxes.xls file to fill in the “Total Taxes” column with the following tax structure. If you make $27,500 or less, you pay 12% in taxes. If you make more than $27,500, you pay 15.5% in taxes. Make sure you use the IF command. Answer: Excel Tutorial - Page 55 Practice Challenge Use the Taxes.xls file to fill in the “Total Taxes” column with the following tax structure: If you make $25,000 or less per year, you pay 15% on your income. If you make more than $25,000 per year, then you pay 18.5% of all income over $25,000 plus 15% of the first $25,000. Read that carefully. (This more like the U.S. tax system, where we have tax “brackets.”) Answer: Excel Tutorial - Page 56 The VLOOKUP command In some situations, you may have a large amount of data in two or more columns and your task is to look up values in one column and return a value from a different column (in the same row). Example The file CarSales.xls gives a list of 450 salespeople. Column A gives the salesperson’s ID number and Column B gives their sales for the month. As a manager, you want to lookup any salesperson by their ID number, type it into Cell D2, and have their sales total returned in Cell E2. The VLOOKUP command will do this, but you have to be careful with the syntax. The form of the command is as follows: VLOOKUP(lookup_value,table_array,col_index_num,range_lookup) where lookup_value is the value you are looking up, table_array is the entire set of data from in which you are looking up values and returning values, and col_index_num is the column of data that gets returned once the lookup value has been located. We will not use the range_lookup parameter. Excel Tutorial - Page 57 In our example, we want to look up the value in D2 somewhere in the table array that starts with cell A1 and extends down to cell B451. Upon finding the correct number, it should return the value in column 2 of the table array. So, our command would look like this: =VLOOKUP(D2,A1:B451,2) This gives the cell or value that you want to first lookup. VLOOKUP will look for this value in the array and then return whatever is in the corresponding column that you specify later in the command. This gives the table array where all the data exists. You must make sure that both the data you are looking up and the data you are going to return are including in this array. The 2 indicates to take whatever value is in the second column of the table array. Important Note: The data in the column that contains the values you are looking up must be sorted so they are in order. If they are not, then VLOOKUP will not work correctly. Practice The file Grades.xls is a list of 100 students, their cumulative GPA’s, and their academic status. A school counselor uses it to lookup GPA’s by student number. Modify this spreadsheet so that Cell F2 returns the GPA for the Student ID number entered into Cell E2. Practice The file Grades.xls is a list of 100 students, their cumulative GPA’s, and their academic status. A school counselor uses it to lookup GPA’s by student number. Further modify this spreadsheet so that Cell G2 returns the academic Status for the Student ID number entered into Cell E2. Practice The file Grades.xls is a list of 100 students, their cumulative GPA’s, and their academic status. A school counselor uses it to lookup GPA’s by student number. Add the title “Probation?” to in Cell H1. Use the IF command to put a “Yes” in Cell H2 if the person’s GPA is below 2.0 and a “No” in Cell H2 if the GPA is 2.0 or greater. Excel Tutorial - Page 58 The HLOOKUP command In some situations, you may have a large amount of data in two or more rows and your task is to look up values in one row and return the value from a different row (in the same column). This command is almost exactly the same as VLOOKUP except that your data is organized differently. Example The file Stocks.xls is a list of prices for a new, popular stock. The Day row gives the number of days the stock has been selling on the NASDAQ. Part of the file looks like this: Since there are over 200 prices, we don’t want to have to scroll to lookup a particular day’s stock price. The HLOOKUP command will do this for us. As you can see below, it’s syntax is almost identical to the VLOOKUP command. =HLOOKUP(lookup_value,table_array,row_index_num,range_lookup) To lookup a stock price in Stocks.xls, the command would be: =HLOOKUP(B4,A1:IV2,2) Make sure you open the file and understand how the command works. The command for the screen shot above is shown below: Practice The file Population.xls gives estimates for the U.S. population from 1790 and forward, as well as fabricated estimates for the percentage of the population that was female. Modify the file using the HLOOKUP command so that when a year is entered in to Cell A5, the correct and corresponding population and percents are returned in Cells A6 and A7. Excel Tutorial - Page 59 The INDEX command There is one more command that can help you look up values in a list of data. It’s more limited that HLOOKUP and VLOOKUP, but it can come in handy for some of our course projects. Example The file Index.xls has two columns of randomly-generated numbers. Open this file and repeatedly change the value of Cell E2, which is labeled Input. Also, look at the formula in Cell E3 to view the INDEX command. See if you can tell what is happening and then come back and continue to read. You’ll notice that if you put a 6 in cell E2, it returns a value of 28. Note that there are several rows which have a 6 in the Random A column. The first one is Row 3, where 6 is associated with 40. Row 20 also has a 6 in the Random A column with a 26 in the Random B column. So the INDEX command does not do a lookup for the value of 6. Instead, it simply looks up whatever is in the 6th row of the specified array (in this case A1:B24) and returns whatever value is in Column 2 of the array. That’s why the command in E3 is: =INDEX(A1:B24,E2,2) This gives the array in which you look for data. This tells you the number of the row to look up. This says to return whatever value is in the second column of the appropriate row. If this had been a 1, it would return the value in the first column. Note that if you type a 1 in Cell E2, Excel will return “Random B” in Cell E3. A picture of this is given below. Excel Tutorial - Page 60 Practice Modify the file Index.xls so that the Array in Cell E3 to be considered is only Cells A7 to B20. (This is a smaller array that the previous example. Also, the first row of the new array, which has the numbers 7 and 14 in it, will now become “Row 1” for the purposes of the INDEX command.) Type in the number 5 into Cell E2. What number do you get? Answer: You should get a 30, not a 28. You may be wondering why you would use INDEX when you have VLOOKUP. Here is an example similar to what you may see in a class project where INDEX might be helpful. Example The file CarIndex.xls is a list of the number of cars sold per day at a dealership during a oneyear period. What we often need to do is randomly pick one of those days and then see how many cars were sold on that day. It’s like having 365 slips of paper (one for each day) and the number of cars sold on a day written on the papers. We put them into a big shoe box and then randomly pick one out, recording the number of cars sold. This is often called sampling and will play an important role in MATH&148. When you have hundreds, or even thousands, of records to choose from, Excel’s INDEX command will allow you to do this. Look at the file: Excel Tutorial - Page 61 In Cell E2, you can check to see that a random number between 1 and 365 has been generated. Do that now. Now, look at the contents of Cell E3. In this cell, the INDEX command has been used to select both columns A and B, Cell E3 is specified to contain the row number we are to look up, and the second column (Column B) is the data to be returned by Excel. If you press F9 repeatedly, you’ll see the equivalent of a new slip of paper being picked out of a shoe box (after the previous slip has been replaced). Now, look at Sheet 2 of CarIndex.xls which has the same data as Sheet 1 does. Hit F9 a few times and you’ll notice it behaves just like Sheet 1 does. However, notice that the Random Number cell has been deleted. Look at the contents of Cell E3. You will notice that we have built the generation of the random number directly into the INDEX command: =INDEX(A3:B367,RANDBETWEEN(1,365),2) Instead of specifying a specific numerical value or cell reference as before, I’ve told Excel to generate a random number between 1 and 365 and to use that as the number of the row to look up. The second column still remains the one that gets returned. A picture of the formula bar is given below: Excel Tutorial - Page 62 Practice The file PhoneLog.xls gives a list of 750 phone calls tracked by a telemarketing company. The call number is logged along with the amount of sale made on that call. In Cell D2, use both the INDEX command and the RANDBETWEEN command to randomly pick one of the calls on the list and return the sale amount for that call. Optional: How I Built the Phone Log File Here’s how I built the PhoneLog.xls file for this example. You may find it interesting as it uses many of the commands in this section. First, I entered 54869 (an arbitrary number) into Cell A2. In Cell A3 I entered =A2+1 so that it would increment the number for me. I then copied Cell A3’s formula down so that 750 data points were generated. In Cell B2 I entered the following: =IF(RAND()>0.7,RANDBETWEEN(15,300),0) What this did was use RAND() to generate a number between 0 and 1. If that number was greater than 0.7, then I used RANDBETWEEN() to generate a sales amount between $15 and $300. If the initial random number was less than or equal to 0.7, then I recorded a sales value of $0. My thought process was that 70% of the phone calls would lead to no sales, while 30% would lead to sales. I then copied Cell B2’s formula down so that 750 sales data points were generated. I selected all the cells in columns A and B that had numbers in them (1500 in all) and copied them with CTRL-C. I then clicked on Cell A2 and did a Paste Special...→Values command so that all the ugly formulas were gone and only the numerical values remained. This is how many of the files in this tutorial were generated. Very easy. Excel Tutorial - Page 63 Graphing Basic Graphing Graphing a large amount of data by hand is tedious and very prone to error. Excel will graph data quickly and easily. Example Fuller and coworkers (1997) estimated the Costs of a medium-sized cotton gin plant as shown in the file Cotton.xls. Open this file to view the data. To graph this data, we will use the Chart Wizard. Here are the steps you take to graph this data. Please do them as they are described below to make sure you get some practice. Select the data: Use your mouse to drag and select all the data to be graphed. Include the heading row. Start the Chart Wizard: Click on the Insert tab on the Ribbon: Select the Chart Type: As you can see, you have many choices of graphs to choose from. In this course, we will mainly use Column, Line, and Scatter graphs. For this example, let’s choose the Scatter choice. We’ll use the first choice in the list, as shown below: Excel Tutorial - Page 64 That will generate a graph that looks like this: This is your first glimpse at what the data looks like. We can refine our picture. Refine your Graph: There is, unfortunately, no uniform way to change all elements of the graph. However, RIGHT CLICK often is a good first step. Let’s do some examples so you can see what I mean. Change the Title: Click on the “Thousands of $” text until it is boxed, like below: Excel Tutorial - Page 65 If you RIGHT CLICK with the mouse inside the box, you’ll get a menu: Although it does not appear above, there is often also a menu for changing the font style, size, color, etc. You can use this to change the title as you see fit. You can select “Edit Text” to be able to change the text as well. I’ll change some things around so it looks like this. Follow along and make the same changes to insure you know how to alter the graph. Excel Tutorial - Page 66 Change the Graph’s Point Style: We can change the color/style of the points as well. LEFT click on one of the points. Then make sure the Ribbon is set to show the Design tab. It should look like this: You can see boxes at the top that allow you to change the colors of the points. Also, you can see many more options by clicking on the drop-down arrow in the lower right corner, highlighted below: Excel Tutorial - Page 67 This will bring up many options, only a few of which are shown below: It’s easy to select one and change the look of the graph. We’ll go to read with shadows: Change the Axes: We can also change the way the axes look. For example, RIGHT click on the vertical axis and then choose “Format Axis…” from the list. Excel Tutorial - Page 68 You’ll get a box like this: Excel Tutorial - Page 69 There are numerous options and changes you can make, as you can see. One common change is to alter the Number settings. Select “Number” from the list on the left: You can choose general numbers, currency, dates, etc. I’ve chosen the second option, “Number” which allows me to specify how many decimal places to show. Choosing 2 and then clicking the “Close” button produces a graph with a vertical axis showing two decimal places, as below: Excel Tutorial - Page 70 Adding Labels to Axes: Sometimes, you will want to add descriptive labels to your axes. To do this, first LEFT click the graph and then choose “Layout” from the Ribbon. This give you many new options, including Chart Titles, Axis Titles, Data Labels, etc. You can experiment with these options on your own. Here, we’ll just add an Axis Title to the horizontal axis. Choose “Axis Titles” button and then “Primary Horizontal Axis Title,” followed by “Title Below Axis.” It looks like this: Excel Tutorial - Page 71 When you select this option, the graph will add an axis title. You can edit this by clicking inside the box and changing the text. Excel Tutorial - Page 72 You can also do this for the other axis as well. Changing the Chart Type: The next big thing to change is the Chart Type. Let’s first suppose we want to add lines to connect the red dots. LEFT click on the graph and then choose the “Design” tab from the Ribbon. Now choose the “Change Chart Type” button on the left: A window will appear that looks like this: Excel Tutorial - Page 73 All the different chart types are listed, so it’s easy to make a change. You can experiment and see how this data would look using different displays. For now, we’ll choose the second option on the XY (Scatter) list: When we do so, the graph changes to the following: Excel Tutorial - Page 74 If the line is too think, we can RIGHT click on the line (not a point) and then choose “Format Data Series…” and then go to the “Line Style” section. Changing the “Width” to 2 produces a nicer look. Excel Tutorial - Page 75 Excel Tutorial - Page 76 Following this same basic procedure, we can view this data as a bar chart. I’ve changed the chart type and the bar colors to blue in the picture below. Can you reproduce the picture? Using these tips and tricks, you can make the graph look any way you want. Keep in mind that the way your reports look is often very important out in the business world. Therefore, you should strive to have professional-looking graphs in MATH116 and MATH&148. Practice In the file Retire.xls you will find a list of annual interest rates and dollar values. The “First Year Income” is the amount this particular retiree can expect to receive in her first year of retirement, given different rates of return on her investments while she works. For example, if she earns an average of 6% annual interest on her retirement investments, when she retires her first year of retirement income benefits will be $98,856. Use this data to create a line graph that looks like the one below. NOTE: If you are using a black and white printed copy of this tutorial, you will not be able to see the colors that are specified so please open the electronic version of the tutorial to see this level of detail. Note that many of the font sizes, colors, and/or styles have changed. You don’t have to get it exactly like you see below...what’s important is that you know how to change each of the components of the graph. Remember, if you want to edit a piece of a graph, start by trying a RIGHT click on that object. Also, selecting different tabs in the Ribbon is also usually useful. It takes some time and practice, but it gets easier if you do so. Excel Tutorial - Page 77 Sherice's Retirement Money $300,000 Income $250,000 $200,000 $150,000 $100,000 $50,000 $0% 2% 4% 6% 8% 10% 12% 14% Rate of Return Note on Bar Graphs The easiest way to create bar graphs is to start with an XY (Scatter) plot and then to change the Chart Type to a Bar graph. If you start with choosing a Bar graph, you can get some nonintuitive results that require some fiddling with the chart’s settings. Try it...you’ll probably find I’m correct on this one. When we get to Histograms, we’ll need to deal with this matter much more carefully, so for now, if you want a basic bar graph, start with an XY (Scatter) graph. Graphing Functions You are undoubtedly familiar with functions from previous math courses. For example, the function f ( x) = x 2 has a graph of a parabola that opens upwards from the origin. We want to explore how to graph this, and any other function, using Excel. There are two main steps: (1) Identify how much of the graph you want to see left to right (the domain), and how many subintervals/points you want to graph so you can create a list of data points in Excel and (2) Use the Chart Wizard to graph the function. Example Let’s graph f ( x) = x 2 from -10 to +10 on the x axis and include 25 subintervals total in our graph. Part (1) We’ll say that the interval we are graphing is [-10,10], which has the general form [a,b]. In these examples and the spreadsheets we will use, a is the leftmost endpoint to be graphed and b is the rightmost. If we take the value b-a, we get the total length of the domain. In this case a − b = 10 − ( −10) = 20 . So our interval is 20 units long (-10 to 0 and then 0 to 10). Excel Tutorial - Page 78 Our next step is to take that entire interval and compute the length of each subinterval. The length of this space will be called the subinterval length and we will use the symbol Δx to represent it. We simply need to take the length of the interval and divide by how many subintervals we have to get Δx . In this case, we have: 10 − (−10) 20 Δx = = = 0.8 25 25 (Technically, if we have 25 subintervals we need 26 points. You always need one more point than you have subintervals {why?}. When graphing functions, we will divide by the number of subintervals, which is always one less than the number of points needed.) The top of the file Parabola.xls shows how these have been entered and computed in Excel. You should open this file and examine the formulas and entries in cells B1 through B5 before continuing. A snapshot is show below: The following picture shows which formulas were used in each cell. (You can use CTRL-` to toggle between Data view and Formula view...it’s a handy feature to know about.) Part (2) In this next part we need to generate a list of (x, y ) points to graph. We start with the left endpoint (a) which is -10 in this example. That’s our first x value. The next x value is the previous one PLUS the length of each subinterval. In this example, it would be −10 + 0.8 = −9.2. The third x value will be −9.2 + 0.8 = −8.4 and so on. We certainly don’t want to compute and type these in by hand so we will have Excel do it. In Cell B8, the value of a is entered. In Cell B9, we need to take Cell B8 and add Δx = 0.8 to it. We could enter into Cell B9 the formula =B8+B5. However, when we copy this down, Excel will assume we want relative references and it will change B5 to B6, which is blank. This is an example of when we need to utilize absolute references to get the results we desire. So what we put into Cell B9 is =B8+$B$5. Recall that the dollar signs lock us into using Column B and Row 5. We can then copy this down to get to +10 for the last x value. Open the file Parabola.xls and see how this was done. Make sure you understand how the x values have been generated and note that there are exactly 26 points (25+1), as discussed before. Excel Tutorial - Page 79 We can now easily generate the y values. In Cell C8, the simply formula =B8^2 is entered to take the x value in Cell B8 and square it. Don’t forget, the function is f ( x) = x 2 , so this makes sense. We now use Ctrl−D to Copy Down our formula and then insert a Scatter graph with no connection lines…just the points. This gives the following graph, making no other special changes: Of course, we could pretty this up, but the main thing we note here is that we usually don’t graph functions with dots. We usually prefer nice smooth curves or lines without the dots. Let’s change the chart type to a smooth line graph with no data points. The choice is highlighted below: Excel Tutorial - Page 80 This gives us the following graph, which we can pretty up with colors, labels, etc. as we see fit. See the sheet “Chart2” of the Parabola.xls file for a nice picture of the parabola. Practice See if you can duplicate the look and feel of the parabola that is shown in the Chart1 sheet in Parabola.xls. Example Let’s graph another function, g ( x) = x − 5 ln x + x 3 . We will use the interval [5,30] and plot 50 subintervals. Rather than go through each step like above, it might be better to simply open the file G(x).xls and see what it looks like. The only thing that has changed is that the function formula is different in Column C, and the interval information is different. This is what the final graph looks like this: Excel Tutorial - Page 81 Please make sure you explore and understand this file before trying the practice problems below. Practice Graph f ( x) = 2 x 3 − 5 x + 3 on the interval [−5,8] using 75 subintervals. See if you can graph this without using or looking at the files Parabola.xls or G(x).xls. If you get stuck, use those to guide you. The goal is to graph this function from scratch. Answer: Your graph should look like this: Graph 1200 1000 800 600 400 200 0 -10 -5 0 5 10 -200 -400 Practice Challenge 2 1 Graph f ( x) = e − 0.5 x on the interval [-5,5] using 100 subintervals. This is a key 2π function in MATH&148 that you will see a lot of when you get there! See if you can graph this without using or looking at the files Parabola.xls or G(x).xls. If you get stuck, use those to guide you. The goal is to graph this function from scratch. Answer: Your graph should look like this: Excel Tutorial - Page 82 Graph 0.45 0.4 0.35 0.3 0.25 0.2 0.15 0.1 0.05 0 -5 0 5 Graphing Histograms Our last goal in this section is to master the method of graphing histograms. These are important in MATH116 and MATH&148 and it’s important you can create these without a lot of fuss (after some practice, of course). Histograms are tools used to depict data and to see how the data is “piled up.” For example, here is a histogram that shows how prices of stocks in the S&P500 are distributed. (The data is completely fabricated!). Excel Tutorial - Page 83 Stock Distribution Each of these bars corresponds to a bin on the x axis. 120 Number of Stocks 100 80 60 40 20 These values are 0 the midpoints of the bins. - $3.35 $9.85 $16.35 $22.85 $29.35 $35.85 $42.35 $48.85 $55.35 $61.85 Price This histogram has information about 500 stocks in it. It is therefore an efficient way to present the data. For example, we see that about 110 stocks have prices that are centered around $22.85. There are 10 bars on the graph, each of which corresponds to what is called a bin. A bin is simply a range of numbers into which a stock price could fall. For example, if a stock price falls between $6.60 and $13.10 (called the bin limits), whose midpoint is $9.85, then it gets placed into the second bin from the left. As more stocks fall into that bin, it rises in height. The more stocks in the bin, the higher the vertical bar. We will discuss how to compute the bin limits, number of bins to use, and the bin midpoints as we progress, but what’s important now is that you have a basic understanding of what the histogram tells you: it counts up values, assigns them to pre−determined bins, and then displays the results with vertical bars. Note: You MAY need have the Analysis ToolPak and the Analysis ToolPak VBA Add−Ins installed to use this feature! To do so, click on the large Office logo in the upper right of the Excel window: Then choose “Excel Options” at the bottom of the menu that appears. You’ll get a screen that looks like this: Excel Tutorial - Page 84 Click the “Add-Ins” from the list on the left and then the “Go…” button near the bottom of the screen. This will bring up a list of Add-Ins you can install. (You may need your Office disk to do so.) We suggest you add the Analysis TookPak, Analysis ToolPak-VBA, and the Solver Add-In modules. BACK TO HISTOGRAMS: The major steps to graphing a histogram are as follows: Excel Tutorial - Page 85 Step 0: Get the data in a spreadsheet if it’s not already there Step 1: Determine the Minimum, Maximum, and Range of your data to determine the bin limits, bin widths, and midpoints. Step 2: Use the FREQUENCY command to count how many data points are in each bin. Step 3: Insert and format a vertical column chart to create the histogram. Let’s dissect these steps one at a time using the Stock Data shown above. Open up the file SP500.xls and follow the steps below carefully. Do one at a time. Do not move to the next step until you understand the current one. Step 0: Open the file SP500.xls. The data is already entered for you. Bins and Midpoints Step 1: (As you move through these steps, you can check the “Results” Sheet to see what is being discussed.) Let’s first count how many data points we have. In Cell C3, type “Data Points” and use the COUNT command in Cell D3. (You should get 500.) Label Cell C4 as “Min” and use the MIN command in Cell D4 to find the minimum stock price. (You should get 0.15) Label Cell C5 as “Max” and use the MAX command in Cell D5 to find the maximum stock price. (You should get 64.13) Label Cell C6 as “Raw Range” and compute the Range of data in Cell D6. (You should get 63.98) Label Cell C7 as “Subintervals.” We need to determine how many bins (i.e. subintervals) to use. If we use too few or too many, we get very inaccurate and useless histograms. Therefore, the number of bins, and hence the bin width, is important to pay attention to. (See this link for an interactive demonstration on how bin width can affect the look of the histogram.) In this course we will use the following formula to estimate the number of bins to use. We let N be the number of bins and n be the number of data points in the set: N = 1 + 3.3 log(n) In this file, we have n = 500 so the formula give us: N = 1 + 3.3 log(500) ≈ 9.9 In general, let’s agree to Round Up to the next integer to get the number of bins. (We can’t have 9.9 bins, right?) Hence, we have 10 bins. When we graphed functions we determined our interval, [a,b]. We’ll do the same here. We could take the min and max to be the endpoints of the interval, but if they are not nice numbers, it’s sometimes better to round them a bit. In general, round down to the nearest integer for the left Excel Tutorial - Page 86 endpoint and round up to the nearest integer for the right endpoint to make sure all your data points are in your final interval. Label Cell C8 as “a” and Cell C9 as “b.” Use the ROUNDUP and ROUNDDOWN commands to compute these. (You should get a = 0 and b = 65. ) Label Cell C10 as “Bin Range” and compute the range for the interval [a,b]. (You should get 65.) Label Cell C11 as “Delta X” and compute this value by dividing the range by the number of bins. (You should get 6.5) At this point, the spreadsheet should look something like this: The formulas in column do look like this: Now you can create a list of bin limits, starting with a = 0 and ending with b = 65 by adding Delta x to the previous bin limit. See the list starting in Cell D15 of the sheet “Results” if you are not sure what is meant. This is very similar to what we did when we generated the list of x values when we were graphing functions. Before you go on, makes sure you create your own bin limit list on the Data sheet. It should be created in Cells D14 to D25, as shown in the “Results” sheet. The bin limits you just created are the upper limit of the bin. That is, when Excel goes to assign a value to a bin, it checks to see if it is less or equal to that bin limit value (but larger than the next lowest bin limit). If so, it assigns that data point into that bin. Hence, if the bin limit is 13, then a stock price of $13 will be assigned to that bin, not the one above it. Excel Tutorial - Page 87 The last step is to find the midpoint of each bin. This is not hard. The midpoint of each bin is simply the computed bin limit minus one half of Delta x. Bin Midpoint Δx Half of Δx Bin Limit Label Cell E14 as Midpoints and then compute the midpoints of each bin. For example, the first midpoint in Cell E15 would be computed with =D15−0.5*$D$11. Note the $ sign is needed for an absolute reference so we always subtract the value of Delta x. We can copy this down to get the rest of the midpoints. Note that the first midpoint will be −3.5 which makes no sense in this context. Hence, we will simply replace it with a dash (“−”) instead. Here is what our sheet looks like up to now: The formulas for these latest computations are shown below: Excel Tutorial - Page 88 Frequency Command Step 2: Once all of Step 1 is done, we are done with the hard part. Now we can use the FREQUENCY command. This command computes how frequently data fall into particular bins. The general format for this command is: =FREQUENCY(data_array,bins_array) As you can imagine, the data_array is the range of cells that holds your data, and the bins_array is the range of cells where you have your bin limits. The FREQUENCY command has the great advantage that if you change you data in your data array, the frequency counts will automatically update. Hence, your counts are always up to date and if you have a histogram that is based on those counts, the graph will also stay up to date. Because we are going to fill in several cells at once, we select all the cells where we want frequency counts to go. They are highlighted below: We now enter the command by beginning to type the following command into cell F16: Excel Tutorial - Page 89 Note: We are NOT using the Midpoints yet! IMPORTANT!!! Since we are wanting Excel to do computation for SEVERAL cells at once, we cannot just hit the Enter key as normal. That would only compute the frequency for the first cell. Instead, we use SHIFT-CTRL-ENTER. That is, hold down both the SHIFT and CTRL keys down and then hit the ENTER key on your keyboard. If you do it correctly, you’ll get the following: If you did not hold down the proper keys correctly, you may not get all the counts to show up. So make sure you have this before you move on. Formatting the Histogram Step 3: We now create a basic Column graph from the data in cell range F16:F25. First we select that data range: Excel Tutorial - Page 90 Next, insert a 2-D column chart: This gives the following crude graph: First, let’s give it a title. Click on the graph and choose the “Layout” tab in the Ribbon. Then choose the “Chart Title” button and the “Above Chart” option: Excel Tutorial - Page 91 Then edit the title to “SP500” to produce this graph: The vertical axis gives the bin counts, as we want. But notice that the horizontal axis is labeled 1 to 10 (for the 10 bins). We want to replace those numbers with the mid-points of each bin, which are located in Column E. To do this, RIGHT click on one of the vertical bars until a menu appears like this: Excel Tutorial - Page 92 We want to choose the “Select Data…” option from the list to get this window: Notice that on the right, there is a place to edit the “Horizontal (Category) Axis Labels.” Excel Tutorial - Page 93 So click on the “Edit” button and you’ll get a window that allows you to specify which labels to use: Our midpoint labels are in cells E16:E25 so use your mouse to highlight that range of cells: That should produce the following graph: Excel Tutorial - Page 94 Since most histograms have little space between the vertical bars, we fix that next. Once again, RIGHT click on one of the data bars and now choose the “Format Data Series…” option: This will produce a window that allows you to change the “Gap Width” of the chart: Excel Tutorial - Page 95 Depending on your preferences (or your instructor’s preferences), you will typically want a gap width between 0 and 5%. We’ll choose 5% here so that the bars can be distinguished from each other but that the space between them is very small. Here’s the result: Finally, the “Series 1” label on the right serves no useful purpose for this graph. So RIGHT click on it and then choose “Delete” from the menu. Our final graph looks like this, and you should have the same thing on your screen: Excel Tutorial - Page 96 Example The file Disney.xls has a list of volume for Disney stocks on several trading days. In the sheet called “Data and Student Workspace,” create a histogram with the data that looks very similar to the following graph. Your x−axis labels may be slightly different. Check the sheet called “Completed Histogram” to see how I got the graph. Disney Stock Volume 20 Days 15 10 5 0 2800 6800 10800 14800 18800 22700 26700 30700 Shares Traded Example The file Basketball.xls has a list of heights (in feet) for professional basketball players. Open the file and create a histogram of this data. Excel Tutorial - Page 97 Example The file GPA.xls has a list of cumulative GPA’s for SCCC students. Open the file and create a histogram of this data. Trendlines Trendlines are basically formulas that have been extracted from a set of data. While the issue is a bit more complicated than that, we don’t need to get into the details too much in this tutorial. We use Trendlines when we have a series of data in (x, y ) format and we want to find the equation of a line, quadratic, or some other function that fits the data relatively well. The first step to creating a trendline is to graph the points using (XY) scatterplots. After that, we run the trendline routine. Example The file Shrinkage.xls has data about the amount of weekly merchandise lost to shoplifting and damage (called shrinkage) as it relates to the average number of clerks on duty. A sample of 7 weeks worth of data is shown. Managers want to see if there is a relationship between these two variables and if so, they want to predict shrinkage from the number of clerks on duty. First, let’s graph this data using a simple (XY) scatter plot without any lines connecting the data points. As a review, you may want to open the file and make sure you can get a graph like this: Excel Tutorial - Page 98 Next, RIGHT click on one of the blue data points until the menu appears: We will choose the “Add Trendline…” option. You should see this screen: Excel Tutorial - Page 99 This is where your intermediate and college algebra background will come in handy. You’ll see a list of possible functions that could model this data. In this case, our data looks very linear so we’ll keep the default choice of “Linear.” Do no click the Close button yet! We want to display the linear equation that best fits this data, so check the “Display Equation on chart” box: This should generate the following graph when you click the Close button: Excel Tutorial - Page 100 You will notice that a straight line has been drawn on the graph that corresponds to the linear formula y = −3.0328 x + 52.508 . This equation is called the “line of best fit” because it is the line that best fits this data. (No other line comes closer to fitting all of these points.) Now, the equation that shows displays only a certain number of decimal places. If you want more (or less) you can edit that as well. To do so, RIGHT click on the trendline equation and choose “Format Trendline Label…” from the menu: On the window that appears, choose the “Number” option from the Category list and then type in how many decimal places you want displayed. We’ll do 10 for this example: Excel Tutorial - Page 101 This gives you the equation with many more decimal places showing: IMPORTANT NOTE: The default number of decimals that show in a trendline (usually three) are NOT necessarily rounded for you. To make sure that you have the level of accuracy you desire, you should absolutely tell Excel to display several decimal places (as we just demonstrated) and then round appropriately!!! The LINEST Command Sometimes, you may want the actual numbers that appear in the trendline equation to be deposited into a cell so you can compute with them. To do this, we use the LINEST command, which has the formt: LINEST(known_y’s, [known_x’s],[const],[stat]) Excel Tutorial - Page 102 For now, only the known-y’s and known_x’s are useful for us. They are, of course, just the y and x values, respectfully, used to create the graph. To use this command, you highlight TWO empty cells…one for the slope of the line and one for the y-intercept. We’ll do this in cells E2 and F2. Like the FREQUENCY command, we start typing the command directly but don’t use the ENTER key right away. The command looks like this for this example: Since we want Excel to compute for more than one cell, we have to once again use SHIFTCTRL-ENTER. When we do this we get the following: We can now increase the size of these cells and tell Excel to show more decimal places. More importantly, we can compute with these numbers without losing any accuracy through rounding. Practice Use the file TotalCosts.xls to find the line of best fit trendline for the data given. Answer: Excel Tutorial - Page 103 Practice Use the file Demand.xls to find the line of best fit trendline for the data given. Answer: Linear trendlines are not the only kind we can generate. We can also do quadratics (Excel calls these polynomials of Order 2), log graphs, and exponential graphs. In MATH&148, we’ll see how these are useful. Example Open the file Shoes.xls to see data about how much it cost to produce shoes in 1937 (actual data!). While the data looks linear, we may also suspect that it is quadratic. We can produce a scatter plot, as usual, and then Start our Trendline tool: Excel Tutorial - Page 104 Note that we have selected “Polynomial” with “Order” 2. This is a quadratic of the form y = ax 2 + bx + c . The order of a polynomial tells you the highest power you find in the function. When we select this and use the Options tab to specify the equation, we get the following graph: Excel Tutorial - Page 105 You can see that this is not a straight line but is actually a small piece of a parabola. The equation shown is also (obviously) not linear as well. In this way, you can take data points and fit them with different function models. Some models are better fits than others, but your coursework will have more to say about that. Well, that’s the end of the tutorial. Please keep a copy of this around so that you can refer to it during MATH116 and MAH&148. We’ve covered a lot of ground so we’re all bound to forget some of the details we’ve encountered. Good luck with your projects. Excel Tutorial - Page 106 Excel Tutorial - Page 107