The words you are searching are inside this book. To get more targeted content, please make full-text search by clicking here.
Discover the best professional documents and content resources in AnyFlip Document Base.
Search
Published by IKBN Peretak, 2021-07-28 00:05:57

Microsoft Excel Advanced

Microsoft Excel Advanced

Microsoft Office Excel 2010 Advanced 296

To add a title to the chart, choose Layout → Chart Title:

This action will display the following menu:

You can use these options to decide if and where to display a title. For this example, the Above
Chart option is selected.
This will display a new Chart Title element above the PivotChart:

At this point a title can be entered by typing it in the region provided. If the chart already had a
title, you could use the menu options to automatically position the existing title above the
chart, or as an overlay on the chart:

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 297

With the Axis Titles button, you can create titles for your horizontal and vertical axes:

As before, a region will become available to enter an axis title:

If you choose Layout → Legend, a menu will appear with options for positioning the PivotChart
Legend:

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 298

In this example, the Show Legend at Top option is selected. Here is the result:

If you choose Layout → Data Labels, you will see options for displaying data labels in your
PivotChart:

These layout options will display the actual data to add detail to the standard graphical
representations (like bars or columns). (Notice that each option has a thumbnail indicating
where the data will be placed.)

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 299

The following image shows an example of data labels applied to the outside end of the columns
in the PivotChart:

Choosing Layout → Data Table will reveal options to add a data table to your PivotChart. (A
data table provides an alternative to data labels. Instead of placing specific values right with the
corresponding column or bar on the PivotChart, a data table will include the numerical data
values in an organized table below the chart.)

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 300

The following image shows a simple bar PivotChart with a data table and data labels for the
sake of comparison:

Our next layout button is in the Axes group and is labeled Axes. This button will give you
options for changing the layout of the horizontal and vertical axes:

For the horizontal axis, you can choose:
 None: Do not show the horizontal axis
 Show Left to Right: The default for most chart types with labels listed from left to right
Show Axis Without labeling: Do not show any labels or data on the horizontal axis
 Show Right to Left Axis: Switch the orientation of the horizontal axis, so the vertical axis
is on the right

For the vertical axis, you can choose:
 None: Do not show the vertical axis
 Show Default Axis: Show the vertical axis on the left
 Show Axis in Thousands/Millions/Billions: Incremental numbers on the vertical axis will
use a scale based on chosen unit
 Show Axis with Log Scale: The numbers on the vertical axis and the corresponding
graphical data will use a base 10 logarithmic scale

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 301

You can also add (or change the layout of) horizontal and vertical gridlines with the Gridlines
command:

Gridlines can help the user determine levels in a chart with more accuracy:

You can apply no gridlines, major gridlines (spaced at each label), minor gridlines (spaced
evenly across the interval for a label), or both minor and major gridlines. The above image
shows a PivotChart with major and minor horizontal gridlines, but only major vertical gridlines.

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 302

Lesson 3.4: Advanced PivotChart Tasks

Just like PivotTables, PivotCharts can be based on external data sources, analyzed with Slicers,
incorporated as part of a scenario report, and even used with PowerPivot. Having acquired a
solid understanding of the fundamentals of PivotTables and PivotCharts, it is time to cover
some of these more advanced concepts.

Creating a PivotChart Based on External Data

The process for creating a PivotChart based on external data is almost the same as for a
PivotTable based on external data (since when you create a PivotChart a corresponding
PivotTable is created as well).

To start, choose Insert → PivotTable → PivotChart:

In the Create PivotTable with PivotChart dialog, select the “Use an external data source” radio
button and then click Choose Connection:

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 303

In the Existing Connections dialog, select the connection to the external data that you want to
use:

In this example, the connection is to an Access database table called testTable. After selecting
the connection, click the Open button at the bottom of the Existing Connections dialog:

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 304

Then, you will see the connection name in the Create PivotTable with PivotChart dialog:

Click OK to create an empty PivotTable and PivotChart with a Field List drawn from the external
data source. When you see the empty PivotTable area and corresponding Field List, drag the
fields down to the appropriate boxes in the Field List (just like before) to add data to the
PivotChart.

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 305

It may be the case that you already have data in your workbook that is based on an external
data source. If this is the case, select the range of data that you want to base the PivotChart on,
and choose Insert → PivotTable → PivotChart:

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 306

In the resulting dialog, make sure that the selected range is correct, specify a location for the
PivotChart, and then click OK:

(The “accdb” file extension visible in the Table/Range textbox indicates that the source for this
worksheet data is an Access database file.)

When you click OK, a PivotTable area, PivotChart area, and Field List will be created. The fields
in the list will be from the data range (based on an external source) that you selected.

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 307

If you choose Data → Get External Data, you will see an option for retrieving data from an
Access database:

Since information in a database is arranged in tables, this kind of external data is ideally suited
to a PivotTable or PivotChart! When you click the From Access option, a navigation window will
appear. You can use this window to browse to an Access database:

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 308

When you have selected the database that you want to use as a source and click Open, an
Import Data dialog will appear:

Simply select the PivotChart and PivotTable Report radio button, specify a location for the data,
and click OK. This will create an empty PivotTable and PivotChart and a Field List with fields
drawn from the external data, just as before.
If you choose another type of source data (like a text or XML file), you will not see the
PivotChart option in the Import Data dialog:

To base a PivotChart on this external data source, you must click OK to this dialog to import the
data into a worksheet as a regular table of data. Next, select the range and create a PivotChart
as discussed before. The resulting PivotChart will be based on the data in your worksheet
(which is in turn based on data from an external source).
Remember, just like a PivotTable or a regular table based on external data, you should use the
Refresh option if you want to update the PivotChart with changes made to the underlying
source data. If your PivotChart is based on a data range in an Excel worksheet, and that data
range is in turn based on an external data source, you should refresh the data range in the
worksheet before refreshing the PivotTable.

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 309

Creating a Slicer

Slicers are an exciting new tool for Excel 2010. In Lesson 2.5 we discussed Slicers in the context
of PivotTables. Now we will see what can be done with Slicers and PivotCharts.

In the following example, we have a basic PivotChart that shows sales and profit for various
geographical areas under the direction of different salesmen.

You can use a Slicer with a PivotChart in almost the same way that you would with a PivotTable.
To create the Slicer, click in the chart and then choose Analyze → Insert Slicer:

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 310

In the Insert Slicers dialog, we will select the fields that we want to work with:

When you click OK, you will see the Slicers:

Now it is time to use the Slicers to find exactly what we want. The idea is the same as it was for
PivotTables. Click in a Slicer to select an item (or Ctrl-click to select multiple items) and the
other data will be filtered out of the chart. You can make selections in different Slicers to
combine the filters.

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 311

Let’s suppose we want to see the profit for A Smith and M Parker for the Mideast area. To do
this, we will click A Smith in the Salesman Slicer, and then hold the Ctrl key and click M Parker.
Next, we will click Mideast in the Area Slicer. The other two Slicers, Product and Profit, will
show results that reflect the items selected above.

The results of the Slicer choices are reflected in the PivotChart:

To clear the Slicers, click the button in the upper right of the Slicer.

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 312

If you click the arrow on the Slicer button on the Analyze tab you will see a Slicer Connections
command:

This command will invoke the Slicer Connections dialog:

Here you can disconnect a Slicer from the underlying PivotTable and PivotChart. This will
basically make the Slicer inactive: if you click an item in the disconnected Slicer, nothing will
happen with the PivotTable, PivotChart, or the other Slicers.

To re-connect the Slicer, just select it again in the Slicer Connections dialog and click OK.

Creating a PivotTable and PivotChart from a Scenario

In Lesson 1.2, we discussed creating scenarios in Excel. As you might recall, a scenario is a set of
cell values that is stored and substituted into your worksheet at your convenience. Since the
rest of the data in the worksheet will be fully calculated based on the scenario you use, you can
compare and contrast the results of one scenario with another by switching between them.

It is also possible to create a scenario summary in the form of a PivotTable. If you have a
PivotTable, you can then create a PivotChart which you can use to build a graphical
representation of your scenarios.

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 313

As an example, look at the following worksheet.

The worksheet shows financial data for a chain of fictional businesses with a location in each of
the cities listed. For each city, there is a corresponding scenario with projected changes in the
financial data.

To see the list of scenarios, choose Data → What-If Analysis → Scenario Manager.

This action will display the Scenario Manager dialog, where you can see a list of the scenarios
that are saved with the workbook. You can select a scenario and click the Show button in the
dialog to recalculate the worksheet data based on the selected scenario. To compare the
scenarios you could show each one, one after the other, but you would not see the results of
the scenarios at the same time.

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 314

Another way to look at the scenarios is to create a scenario PivotTable. To start, click the
Summary button in the Scenario Manager dialog:

Then, in the Scenario Summary dialog, select the “Scenario PivotTable report” radio button, and
specify the range for the “Results cells” that you are interested in:

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 315

Here we have selected the range H2:H6, which contains the Profit for Boston, New York,
Atlanta, and Miami, as well as the combined profit for all city locations. (The values in these
result cells will change depending on the scenario used.) To create the PivotTable, click OK in
the Scenario Summary dialog.

Here is the result:

You will notice that the column labels are the cell references for the range of result cells we
chose. These cells correspond to the profit for each city (H2 to H5) and the total profit (H6). To
make the table easier to understand, we can re-label these columns:

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 316

Now that we have a PivotTable with the results from all of our scenarios, we can create a
PivotChart. To do this, just click in the PivotTable, click the Insert tab, and use the Chart group
to pick a chart type:

For this example, a 2-D column chart has been selected:

The PivotChart shows the results of all five scenarios (as specified by our choice of result cells).

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 317

For even better analysis, click in the PivotChart and choose Analyze → Insert Slicer:

In the Insert Slicers dialog, we will choose “$B$2:$F$5,” since this is the range for the changing
cells in all five scenarios:

When we click OK, our Slicer will appear:

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 318

Now we can easily look at whatever scenario we want. For example, suppose we choose the
Atlanta scenario by itself:

Here is the resulting PivotChart:

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 319

Now, suppose we want to compare the Current state of affairs with the scenarios for New York
and Miami:

This makes it easy to view multiple scenarios at once.
Creating PivotCharts with PowerPivot Data
In Lesson 2.4, we discussed a powerful Excel add-in called PowerPivot. With PowerPivot, you
can import and integrate multiple data sources (from multiple external files) and then pivot the
combined data almost as if it came from a single table.
Now we will explore how to use PowerPivot with PivotCharts. To begin, we will open Excel and
make sure that the PowerPivot add-in is installed:

Next, we’ll launch PowerPivot by clicking the PowerPivot Window button:

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 320

Now we can see the data from two external data sources. One sheet contains data imported
from an Access database:

The other sheet has data from a separate Excel 2010 workbook:

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 321

To see the PivotChart options, click Home → PivotTable arrow:

You will see a PivotTable/PivotChart menu:

This menu has options for a number of PivotTable/PivotChart combinations. These include:
 A single PivotChart on a sheet
 A PivotChart and a PivotTable arranged horizontally on a sheet
 A PivotChart and PivotTable arranged vertically
 Two PivotCharts on a sheet arranged horizontally
 Two PivotCharts on a sheet arranged vertically
 Four PivotCharts on a sheet
 A flattened PivotTable (for Excel Services)

For the purposes of this example, we will choose a single PivotChart:

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 322

Then you will need to choose where in Excel to place the chart:

In this case, we will place the PivotChart in a new Excel worksheet:

There will now be two new worksheet tabs at the bottom of the Excel screen: one for the
PivotChart itself (an empty chart area and corresponding Field List), and another for the
PivotChart data (an empty PivotTable and a corresponding Field List).

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 323

The data can be added to the PivotChart by dragging the fields you want down to the boxes at
the bottom of the Field List. Because the Field List is based on a PowerPivot connection that
integrates two data sources, you will see two sets of fields in the list:

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 324

The two sections in the Field Lists are named after the corresponding data sources that have
been imported into, and combined, with PowerPivot.

Here is a sample PivotChart generated from the combined Field List:

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 325

As with any PivotChart, choosing Analyze → Insert Slicer, will allow you to create Slicers:

Because the data for the PivotChart comes from different sources, there are two distinct
sections in the Insert Slicer dialog:

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 326

To create the Slicers, select the fields that you want to use and click OK. In the dialog above,
there are eight Slicer fields selected. Here are the results:

PowerPivot, PivotTables, PivotCharts, and Slicers, are amazing tools. Even learning to use them
at a basic level will greatly enhance the power and flexibility of data analysis in Excel.

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 327

Section 3: Review Questions

1. Which of the following statements outlines an advantage of using PivotCharts over
regular charts?

A. They can change what they represent depending on how you pivot the data
B. They can be used with Slicers
C. A single PivotChart can be used to show the same information as multiple standard

charts
D. All of the above

2. What is the best chart type for a PivotChart?
A. Pie chart
B. Bar chart
C. Scatter chart
D. None of the above

3. When you click a label in a Slicer it is a lot like…
A. Filtering the data
B. Re-formatting the data
C. Adding new data
D. Validating the PivotTable or PivotChart data

4. What chart types can you not use with a PivotChart?
A. Surface charts
B. Stock charts
C. Bubble charts
D. Scatter charts
E. All of the above

5. What is the best way to modify Slicers?
A. Using the Format tools on the Home tab
B. Using the Styles tab
C. Using the Format Filters tab
D. Using the Slicer Tools tab

6. When you click on a PivotChart, what contextual tabs will you see?
A. Options and Design
B. Design and Layout
C. Design, Layout, Analyze, and Format
D. Design, Style, Analysis, and Format

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 328

7. Which of the following statements is true? (Select all that apply.)
A. A PivotChart will almost always have an associated PivotTable
B. You cannot use a PivotChart on data that has been combined with PowerPivot
C. If you pivot the data in a PivotTable, the PivotChart associated with it will not change
D. You can refresh the data in a PivotChart

8. Which of the following combinations is not possible?
A. A PivotChart and a PivotTable
B. A standard chart and a Slicer
C. PowerPivot data, a PivotChart, and a Slicer
D. A standard table and a standard chart

9. Which of the following functions can be used to summarize numerical data in a
PivotChart or PivotTable?

A. Sum
B. Average
C. Count
D. StdDev
E. All of the above

10. Which of the following is not a recommended data source for a PivotTable or
PivotChart?

A. A Word document
B. An Access Database
C. A text file
D. A database query

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 329

Section 4: Advanced Excel Tasks

In this section you will learn how to:
 Use the PMT and FV functions
 Understand and use logical functions
 Use the IFERROR function with array formulas
 Differentiate between VLOOKUP and HLOOKUP
 Find an exact or approximate match with VLOOKUP
 Use VLOOKUP in an array formula
 Understand AutoFill lists
 Create, use, modify, and delete custom AutoFill lists
 Link, consolidate, and combine workbooks
 Pivot consolidated data using the PivotTable and PivotChart Wizard

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 330

Lesson 4.1: Using Advanced Functions

Excel 2010 puts a tremendous variety of built-in functions at your disposal. Some of these
functions, such as Average and Sum, are quite straightforward and easy to apply. There are
some other functions however, that are not as easy or intuitive, but are still very useful.

In this lesson, we will take a look at some of Excel’s more advanced financial functions, namely,
the PMT (payment) and FV (future value) functions. We will also explore Excel’s logical
functions and look at how they can be used in a worksheet.

Using the PMT Function

The PMT (payment) function is one of Excel’s more advanced financial functions. If you have a
loan at a constant interest rate and you are paying the loan with fixed periodic payments, the
PMT function will calculate the amount of a single loan payment.

To select this function, click Formulas → Financial → PMT:

For example, if you take a loan of $10,000 at 6% annual interest over 4 years, you can use the
PMT function to calculate what the monthly payment on the loan will be.
To start, let’s look at the list of arguments for the PMT function:

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 331

The Rate argument is the interest rate per payment period. This means that if you have a 6%
annual interest rate, and your payments will be paid once a month, the rate will be 6%/12.

The Nper argument is the number of payment periods required for the loan. If you are repaying
the loan over four years, the Nper argument would be 4*12, for four years of 12 monthly
payments.

The Pv argument is the present value of the loan; in this case, the face value of the amount you
are borrowing. If you borrow $10,000, the Pv is 10000.

The Fv argument and the Type argument are optional in this function. You can use an Fv
argument to specify an amount that is left outstanding after the loan payments are made for all
payment periods. If you leave this option out, it will default to 0, meaning that the loan will be
paid in full at the end of the payments.

The Type argument will specify if the payment is made at the beginning or end of the payment
period. If you enter an argument of 0, payments will be due at the end of the payment period.
With an argument of 1, payments will be due at the beginning of the period. If you leave this
argument out, it will default to 0.

For the case described above, you would have a Rate of 6%/12, an Nper of 4*12, and a Pv of
10000, which translates to a loan for 10000 dollars at 6% paid monthly over 4 years. The
resulting function arguments look like this:

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 332

You will see that a formula result of -234.85 has been provided in the dialog. This is how much
the monthly payment would be. If you click OK in the dialog, the formula will be entered and
the value will appear in the active cell in the worksheet.

If you choose to type the function directly into the formula bar, rather than using the Insert
Function features, your function should look like this:

Notice that this typed-in function contains the same arguments as before, with each argument
separated by commas. If you wish, you can also use cell references as function arguments,
instead of direct numerical values:

In this worksheet, the PMT functions in the “Payment per month” column use cell references,
as shown in the formula bar.

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 333

Remember, if you are using worksheet values as function arguments, you can just click on a
given cell to enter a reference to the cell containing the value into the Function Arguments
dialog.

Using the FV Function
Another interesting financial function is the FV or future value function. This function returns
the future value of a series of periodic payments to an investment at a fixed interest rate. For
example, if you put $5,000 a year into an investment that yields 6% annual interest, the FV
function can tell you how much your investment will be worth after a given period.
Let’s begin by examining the arguments for the FV function.

The Rate argument is the interest rate that you expect to earn on your investment. If you are
contributing payments to your investment once a year, you should use an annual rate. If you
are paying into your investments on a monthly basis, you should use a monthly interest rate.
The Nper argument is the number of payment periods over which you will contribute to your
investment.
The Pmt argument is the payment that you make each payment period.
The Pv argument is an optional lump sum that you can begin with. (By default, this argument is
0.) The Type argument will specify if the payment is made at the beginning or end of the
payment period: enter 1 for payments at the beginning of the payment period and 0 for
payments at the end of the payment period. (By default, this argument is also 0.)

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 334

If you contribute $5,000 dollars a year at an interest rate of 6% for 10 years, the function
arguments would be as follows:

At the end of 10 years, you would have almost $66,000:

Notice the FV function in the formula bar.
Just as with the any other function, you can use cell references as function arguments for the
FV function instead of direct numerical values.

Understanding Logical Functions
Excel 2010’s logical functions are:

 AND
 OR
 NOT
 FALSE
 TRUE
 IF
 IFERROR
These logical functions are important when doing advanced work in Excel because they can
help you control the behavior of your worksheets based on specific logical conditions.
The AND function will return true if all of its arguments are true. If one argument is false, the
AND function will return false. For example, the logical statement 1<10 is true, and the
statement 2>1 is also true. As a result, the compound statement 1<10 AND 2>1 is true, because
both of the statements that are being joined by AND are true:

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 335

Notice that the arguments joined by AND are placed in parentheses and separated by commas.
The Excel function =AND(1<10, 2>1) means the exact same thing as saying 1<10 AND 2>1 in
plain English. Because 1 is less than 10 and 2 is greater than 1, the Excel AND function returns
the logical value True.

The following table (called a truth table) may help you understand the AND function. In the last
column of the truth table, you will see the value returned by the function according to the
corresponding values of the function arguments.

A B AND (A, B)
True False False
False True False
True True True
False False False

The logical OR function will return true if one or more of the arguments to the function are
true. For instance, the compound statement 1<10 OR 2<1 is true, since 1 is less than 10. It does
not matter that the statement 2<1 is false, because you have a choice of either 1<10 OR 2<1 to
make the compound statement true. If one or both of the arguments is true, the overall OR
statement will also be true.

In Excel, you compose an OR function as follows.

=OR( argument1, argument2, argument3, argument4,…….argument255).

If one or more of the function arguments is true, the OR function will return true:

Here is a truth table for the OR function:

A B OR(A,B)
True False True
False True True
True True True
False False False

The NOT function has the following structure. =NOT(argument). Basically, if the argument is
true, the NOT function will return false. If the argument is false, the NOT function will return
true. (In other words, not true is false, and not false is true.)

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 336

In the following example, =NOT(10>1) will return false, because 10>1 is true and NOT(true) is
false.

Here is the truth table for the NOT function:

A NOT(A)
True False
False True

The FALSE function will simply return the logical value false. The function takes the form
=FALSE() with no arguments. It is a way of specifying a logical value of false in a cell, formula, or
larger function.

The TRUE function will simply return the logical value true. The function takes the form =TRUE()
with no arguments and is a way of specifying a logical value of TRUE in a cell, formula, or larger
function.

The IF function takes the form =IF(logical test ,value1, value2). This is a very important logical
function. Essentially, if the logical test evaluates to true, the IF function will return value1. If the
logical test evaluates to false, the IF function will return value2.
For example, =IF(10>1,100,200) will return 100, because 10>1 is true. On the other hand
=IF(10<1,100,200) will return 200, because 10<1 evaluates to false.

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 337

The IF function is ideal for making choices based on logical tests. Furthermore, you can nest IF
functions one inside another, like this:

=IF(A1=10,100,IF(A1=5,200,0))

In the case of this IF function, if the value in cell A1 is 10 the function will return 100. If the
value in A1 is not 10, the function will test if the value in A1 is 5. If the value in A1 is 5, the
function will return 200. If it is not 5 (and also not 100) the function will return 0.

Here is the formula in Excel:

When you nest logical functions, you must make sure that the number of closing parentheses
matches the number of opening parentheses used in the function. If you count the parentheses
in the function from the image above, you will see two opening and two closing parentheses:

As with virtually any function, you can use cell references in an IF function as well as direct
arguments.

The IFERROR function is of the form =IFERROR(expression, value if error). Basically, the function
will return the value of the expression if the expression is not an error. If the expression causes
an error (such as a division by zero error) the function will return a specified value that you
supply. Take the following IFERROR function as an example:

=IFERROR(10/A1,1000)

This function will return the value of the expression 10/A1, unless cell A1 contains a value of 0.
If A1 is 0, then 10 /A1 will create a division by zero error, and the value 1000 will be returned:

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 338

Now, the value in cell A1 is changed to 5:

2 is returned by the function because 10/5 =2. Let’s look at another example.

Can you tell what is happening with this formula? If D1 +3 results in an error, then a value of
1000 will be returned. If there is no error, the result of D1 + 3 will be returned. Since D1 is 11,
14 is returned (11 + 3) and displayed in the cell containing the formula.

Now look at this variation:

This time, 1000 is being returned in the formula cell. This means that an error has occurred.
This is because the value in cell D1 is not a value at all: cell D1 contains two I’s. If you try to add
text with a number, you get a value error. Because there is an error, the formula returns 1000.
Of course, you could return almost any type of data if there is an error. Have a look at the
following example:

In this case, we have specified the word “Error” as a return value when the IFERROR function
detects an error. There is an error in this case because cell C1 contains nothing at all, and a
numerical value is required for division.

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 339

Using Logical Functions
Examine the following worksheet:

This worksheet is used to calculate the future budget increase for different divisions of a
fictional company. You will notice that the Miami location has had its budget increased from
1,500,000 to 1,800,000. Also, the L.A. location has had its budget increased from 2,000,000 to
2,400,000. The question that arises here is, “What reasoning was used to arrive at these budget
increases for these cities?”

For the answer to this question, look at the formula bar for a cell from the Budget Increase
column:

Here is the formula from cell F2:
=IF(OR(C2-D2>500000,AND(C2>D2,E2>20%)),B2*1.2,B2)

To understand this formula as a whole, you must first understand how each logical function is
used in the formula. To start, remember that the IF function will return a certain value based on
a logical test:

=IF(logical test ,value if test is true, value if test is false)
In this case, the logical test is:

OR(C2-D2>500000,AND(C2>D2,E2>20%))

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 340

Remember, the OR function will return true if one or more of its arguments are true. The first
argument in the OR function is C2-D2>500000. This is a simple argument that will return true
when the value of cell D2 subtracted from cell C2 is greater than 500,000.

The second argument in the OR function is AND(C2>D2,E2>20%). This is a logical AND function
which will return true only when the value in C2 is greater than the value in D2 AND the value in
E2 is greater than 20%.

If the first argument to the OR function is false, the AND function must return true for the OR
function to be true. Alternatively, if the AND function returns false, the first argument to the OR
function must return true for the OR function itself to return true.

If we use the column headings instead of specific cell references, the logic of this OR statement
reads:

OR(Forecast Revenues-Previous Revenues>500000,AND(Forecast Revenues>Previous
Revenues, %Market Share>20%))

To explain it further: If (%Market Share is greater than 20% AND Forecast Revenues are
greater than Previous Revenues) OR (Forecast Revenues subtract Previous Revenues is
greater than 500000), return true.

When the OR function returns true, the IF function will give the value B2*1.2: the original
budget increased by 20 percent When the OR function returns false, the IF function will give the
value B2: the original budget value.

If you wanted to summarize the formula shown in the formula bar in plain English, you could
say the following: “If the forecast revenues show more than a 500000 dollar increase over the
previous revenues, or if the forecast revenues are greater than the previous revenues and the
market share is greater than 20 percent, the budget will be increased by 20 percent. Otherwise,
the budget will remain the same.”

Logical functions can be difficult to grasp at first, especially if they are nested into a larger
formula. If you are confused by a formula involving one or more logical functions, take your
time and carefully study the function arguments. Study one function at a time until you
understand the logic and the test conditions and the value or values that the function will
return. If you understand each individual function in a formula, pretty soon the entire formula
will make sense to you.

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 341

In a situation like this, with a complex logical formula, it may help to examine the nested
functions in a formula from inside to out. To break this complex formula down once again:

 AND(C2>D2,E2>20%): Returns true if %Market Share is greater than 20% AND Forecast
Revenues are greater than Previous Revenues. (Both must be true.)

 OR(C2-D2>500000,AND(C2>D2,E2>20%)): Returns true if Forecast Revenues subtract
Previous Revenues is greater than 500000 OR result from AND function is TRUE.

 IF(OR(C2-D2>500000,AND(C2>D2,E2>20%)),B2*1.2,B2): IF the OR function returns
TRUE increase the original budget by 20 percent (multiply it by 1.2). Otherwise, keep
the original budget.

Using IFERROR with Array Formulas

In a perfect world, worksheet data would not contain errors. We all know, however, that errors
can easily occur! A typing error, an unexpected formula result, a problem importing data,
poorly designed macros, and bad VBA code can all cause problems for a worksheet. However,
the IFERROR function can help compensate for errors in a worksheet.

First, have a look at the following worksheet which lists a series of distances, times, and speeds.

You can see an error in cell D17. Here is the formula bar for that cell:

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 342

D17 is supposed to display the average speed based on all of the speeds listed in column D. The
problem is that cells D3 and D9 have errors: a division by zero error and a value error. The
AVERAGE function will not work on a column of data that contains an error.

In this example, it is easy to find and correct the errors in the data because there are not that
many rows of data, no data is hidden, and the math (dividing a column of distance
measurements by a column of time measurements to get the speed) is simple. In a larger and
more complex worksheet, however, the errors could prove difficult to deal with.

Fortunately, we have the IFERROR function at our disposal. If we combine this function with the
power of array formulas, we can check our column of data for errors before a calculation is
made.

Let’s begin with a little refresher on the IFERROR function. It has the following form:

=IFERROR(expression, user specified value)

This function will return the value of the expression if the expression is not an error. If the
expression causes an error, the function will return a value that you specify. (Refer to the
“Understanding Logical Functions” concept in this lesson for more information.)

We need to make the IFERROR function test our entire column of data for errors and return the
data only when it is legitimate (no error in the cell). This legitimate data must then be used by
the AVERAGE function to calculate the average of all of the legitimate data cells in the column.

Look at the following potential solution:

=AVERAGE(IFERROR(D2:D16, FALSE))

Breaking down this formula we have:
 IFERROR(D2:D16, FALSE): If the value in the range D2:D16 is not an error, that value will
be returned. Otherwise, a logical FALSE value will be returned.
 =AVERAGE(IFERROR(D2:D16, FALSE)): Whatever is returned from the inner IFERROR
function will be averaged. (The AVERAGE function ignores logical FALSE values.)

Now, we will plug this new formula into Cell D17 of the worksheet to calculate the average,
regardless of cell errors:

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 343

Here is the resulting worksheet:

The formula calculates an average of 0.00. This is a slight improvement over the error value we
received before, but clearly it is still incorrect. What went wrong?
The IFERROR function and the AVERAGE function are not processing the entire range of data.
To make this happen, we have to turn the formula into an array formula. This will allow the
IFERROR function to create an array that holds each expression from the range if it is not an
error and a logical FALSE value when there is an error. The AVERAGE function will then average
this array while ignoring the FALSE values.

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 344

To turn the formula into an array formula you must press and hold the Ctrl key and the Shift key
at the same time that you press Enter to enter the formula:

If you were successful, curly braces will appear around the formula:
The only purpose of the curly braces is to indicate that the formula is an array formula. Note
that the braces cannot be typed in to create an array formula. They must appear as a result of
pressing Ctrl + Shift + Enter.

© 2005-2011 Velsoft Training Materials, Inc.

Microsoft Office Excel 2010 Advanced 345

The following image shows the result with the array formula in place:

Now we can calculate the average speed even with error values in the column of data.
This array formula will work with any type of error value that may arise. Furthermore, this
general idea will also work with functions like SUM, MAX, and MIN, that would typically return
an error in these circumstances.

© 2005-2011 Velsoft Training Materials, Inc.


Click to View FlipBook Version