Professional Documents
Culture Documents
AdvancedTopicsInExcel PDF
AdvancedTopicsInExcel PDF
AdvancedTopicsInExcel PDF
PIVOTTABLES .................................................................................................................................... 5
DEFINED NAMES
Suppose you are performing a lot of calculations on a large data set. It can be time consuming to reference this
data set every time you wish to use it.
So suppose we have 200 SAT scores and we are going to be doing calculations on it. We can define it to a name
to make it easier to call in function. Under the Formulas ribbon, in the Defined Names group, select Defined
Name. In the name, enter SATScores. Under refers to, select cells A1 through A200.
Click OK. Now, let’s calculate the average and standard deviation. In cell D1, enter the formula
=AVERAGE(SATScores). Then, in cell D2, enter the formula =STDEV(SATScores). You will see that this has
performed the calculations for us using the defined names.
DATA VALIDATION
When you create a spreadsheet that uses calculations, it is likely going to be possible to “break” it. For example,
as we saw earlier, if you do a mathematical calculation on a cell with a string, it causes a value error.
Let’s revisit the average speed calculator example we looked at earlier. For the distance, we can allow any number
greater than or equal to zero. For the time, we can allow any number greater than zero. (We cannot allow zero or
we will get a division by zero error.
Select cell B1. Then, under the Data ribbon, in the Data Tools grouping, select data validation. Under Allow, pick
Decimal. Then, under Data, pick greater than or equal to. Finally, for Minimum, enter 0.
PROTECTING SPREADSHEETS
Continuing with our average speed calculator example, let’s say we were going to distribute this and we don’t
want people to change the formulas or layout of the spreadsheet, but we don’t want to lock them out completely
of changing values (otherwise, they can’t use the calculator).
First, select the two cells that we want to allow input into and open the Format Cells dialog. Then, under the
Protection tab, make sure Locked is unchecked. Click OK.
Click OK. Now, click on the Review ribbon, and in the Changes group, select Protect Sheet. Enter a password to
lock the sheet with, and click OK. You will be prompted to enter the password for a second time. Now, try to edit
the two input cells. You will see that everything works as we expect. However, try editing any other cell. It should
give you an error dialog.
LOOKUP TABLES
Sometimes, you may need to create a lookup table. A lookup table allows you to “lookup” one value to get one
or more other associated values. Consider the example of a calculating a student’s final grades. In this case, we
have grades of 94 and higher translating to a 4.0; 88 and higher to a 3.5; 82 and higher to a 3.0; and so on.
In this case, we will use the VLOOKUP() function. VLOOKUP takes three arguments:
• The value you are looking up (example: The student’s final average, in column C)
• The cells containing the lookup table (example: F2:G9)
• The column of the lookup table that we want displayed in the cell (example: 2)
So, in cell D2, our formula will be =VLOOKUP(C2, F$2:G$9, 2). Note that we used absolute references in the
table so that the rows do not change when we drag the cells down.
Then, click OK. The grades less than the average of 81.3 should now be highlighted in red.
• By default, the “reddest” is the minimum value, and the “greenest” is the maximum value. This will throw
our scale off if we do not have a 0.0 and 4.0 in our class.
• By default, the middle “yellow” value will be the median number in the data set. We want this to be a 2.0.
While all of the grades under the final grades column are selected, go to the Conditional Formatting button
again, and this time, select Manage Rules. Then, click on the rule we have set and click Edit Rule. At the bottom,
where it has the three Values across (just above the gradient image), change it so the Type for all three is
Number. Then, set the Values to 0.0, 2.0, and 4.0, respectively. It should look like this:
Click OK. Our scale should have changed to what we are looking for.
There are similar feature to do the same thing with data bars and icons.
Now, suppose a week has passed and we want to load the data. Under the Data ribbon, go to the Connections
group and click Refresh All. A dialog will popup. Open the file demo_enroll_2.csv. We will see that the data
values update.
PIVOTTABLES
PivotTables allow you to easily take large amounts of data and aggregate them.
For example, consider the case where we want to know how many courses were offered in each department that
were face-to-face (F2F), hybrid (HYB), or online (WEB).
First, we need to click anywhere inside our table of data. Then, go to the Insert ribbon, and click the first button,
PivotTable.
When the dialog box pops up, the default settings should be as shown below. Be sure New Worksheet is
selected. Click OK.
From here, we simply need to visualize how we want our PivotTable to look. First, let's create a PivotTable that has
a list of course subject codes down the left-hand side of the screen, and the three delivery formats (F2F, HYB, and
WEB) as columns. We are going to want to know how many courses are in each.
To build this PivotTable, we are going to arrange the fields exactly as we want our final product to look. In the
pane on the right hand side of the screen, we are going to click the SUB field in the list of fields at the top and
drag it down to the Row Labels box. You will see the worksheet update with all of the subject codes.
Next, we want to see the delivery method as the columns. In the pane on the right, click the DEL field and drag it
down to the Column Labels box.
We see it has added the data to our PivotTable, but it added the sum of the CRNs. We want to know how many
CRNs there are. In the pane on the right, in the Values box, click the icon with the downward pointing arrow next
to Sum of CRN. Then, select the Value Field Settings... option.
Now, suppose we want to know how many credits were offered. In the Values box in the right pane, simply click
on Count of CRN and drag it out of the pane. Now, click the CR field and drag it down into the Values box. It,
by default, will show a Count of CR. Using the directions above, open the Value Field Settings window to
change it to Sum of CR. We can see our table has updated.
All we need to do to accomplish this is, in the right pane, drag the DEL field from the Column Labels field to the
Row Labels field.
Now, suppose we want to know not only how many credits were offered, but also home many courses as we
originally had. Follow the directions above for adding the Count of CRN to Values box, but do not remove the
Sum of CR from the Values box. This puts additional data on our table.
To do this, we are going to simply go into the Row Labels box, and click on the SUB field, and drag it down so it
is below the DEL field. Note that a gray line will appear as you drag it to show where it will fall when you release
the mouse.
One thing to note is you don't need rebuild the PivotTable if your data changes. If you update the data on the
original worksheet, you can click anywhere inside the PivotTable on the tab it was created in and, under the
PivotTable Tools group of ribbons, select the Options ribbon. Then, click the Refresh button.