Mastering Microsoft Excel PivotTables

Mastering Microsoft  Excel  PivotTables ® ® TABLE OF CONTENTS Introduction............................................................................
Author: Emil Harris
0 downloads 1 Views 1MB Size
Mastering Microsoft  Excel  PivotTables ®

®

TABLE OF CONTENTS Introduction.........................................................................................................................................................................................................3 The Ins and Outs of Excel® PivotTable and PivotChart Reports, Including How to Create a Stand-alone PivotChart..................................................................................................................4 Creating a Stand-alone PivotChart......................................................................................................................................................5 Use the New Recommended PivotTables Feature to Have Excel® Recommend Different Ways to Summarize Your Data.........................................................................................................6 Create PivotTables Based on Multiple Tables................................................................................................................................7 How to Quickly Drill Down, Drill Up and Cross-drill in Your PivotTable Without Having to Go Back to Your Source Data to Identify Specific Information.........................................10 Change Your PivotTable Field Settings to Summarize the Data in Different Ways From the Default, Such as Average, Minimum, Maximum or Even Custom Settings...................................13 Move or “Pivot” Your Data With a Simple Click of the Mouse.........................................................................................14 Bonus Material................................................................................................................................................................................................16

SYMBOL KEY Symbols used in this workbook: Introduction: A brief overview of the session you are about to begin

Learning objectives: A guide to a session’s key points intended to help focus your attention on important elements and essential take-aways SkillTip: A short, quick and to-the-point productivity tip

Produced by

SkillPath® Seminars The Smart Choice® 6900 Squibb Road • P.O. Box 2768 • Mission, KS 66201-2768 1-800-873-7545

www.skillpath.com www.nationalseminarstraining.com Mastering Microsoft® Excel® PivotTables Copyright © SkillPath® All rights reserved. Access®, Excel®, Microsoft® and SQL Server® are registered trademarks of Microsoft. SkillPath claims no ownership interest in the trademarks.

Introduction This session will show you how to view and organize your Excel® data quickly and easily. You will learn how to access the information you need from hundreds or even thousands of rows of data so you can see comparisons, reveal patterns and analyze trends.

 Learn the basics for using PivotTables so you can quickly find the exact information you need

regardless of the size of the database

 Jumpstart your use of PivotTables with the new Recommended PivotTables feature  Create relationships between tables so you can use one PivotTable to search them all at the

same time

 Drill down, drill up and cross-drill in your PivotTable without the hassle of opening drop-

down lists and searching for items you want to filter

 Learn how to “pivot” your data with a simple click of the mouse

3

The Ins and Outs of Excel® PivotTable and PivotChart Reports, Including How to Create a Stand-alone PivotChart The PivotTable is one of the most advanced and powerful tools found in Microsoft® Excel® and it is one of the most misunderstood tools as well. You can think of a PivotTable the same way as you think of a report in Microsoft® Access®. It is basically a way to create reports from your worksheets. The reports it generates enable you to summarize and organize the data stored in your worksheet, letting you see the “big picture” of what is going on. You can also sort and summarize your data by taking an average or a count. Above all, you can make these changes without changing the original data. Using a PivotTable, you can: 

Sort the data in the PivotTable



Add additional data to the PivotTable



Organize the data into subsets



Change the layout of the PivotTable



Show only the details you want



Summarize the original data in a number of ways

A PivotTable can be created using information stored in a worksheet, from an external data source such as Access® or an SQL Server®, or from several different sources. The best way to understand how a PivotTable works is to examine one. Shown below is a typical Excel® worksheet, containing the sales figures for September. Let’s say you want to determine who your best salesperson is, which region purchased the most, what type of products were most popular and where.

4

Using a PivotTable, you can easily answer all of these questions. This table was used to create the following simple PivotTable by clicking on the PivotTable option in the Tables group on the Insert tab. Notice the PivotTable shows a summary of sales, broken down by product type and region.

There are certain restrictions you need to take into account when creating a PivotTable. The data must be in the form of simple lists, such as the one shown above. Each list must start with a column label, since the label will be used as the field name in the PivotTable report. Each list must contain items similar to each other. For example, one list could contain names and another list could contain numbers. Never mix data types in the same list. If there are any automatic subtotals at the end of the lists, remove them. Also, if you have any filters enabled on your lists, make sure to disable them.

Creating a Stand-alone PivotChart You used to have to create a PivotTable before you could create a PivotChart, but now you can easily make a stand-alone PivotChart with a few simple steps that are outlined below.

1. Select the data that you want to use.



2. Click the Insert tab, click the Recommended Charts option in the Charts group and you’ll see the Insert Chart dialog box, as shown in the following image.



3. On the Recommended Charts tab, select any of the charts with the PivotChart icon by clicking it and you’ll see a preview of it.



4. When you have found the one you want, click the OK button and your PivotChart will be inserted into a new worksheet. Once your PivotChart has been created, you can click on any interactive control and then pick the sort or filtering options you want. 5

Use the New Recommended PivotTables Feature to Have Excel® Recommend Different Ways to Summarize Your Data Excel® now comes with the new Recommended PivotTables feature that will automatically recommend different PivotTables to summarize the data you have selected. This feature allows even the novice Excel® user the ability to create PivotTables with ease. Most of the recommended PivotTables are relatively basic in nature; you can always modify them after they have been created to include more advanced features. The following steps outline the procedure to use the Recommended PivotTables feature.

1. Select the data you wish to use to create the PivotTable.



2. Click on the Insert tab and then click the Recommended PivotTables option in the Tables group, as shown in the image at right.



3. You will then see the Recommended PivotTables dialog box, as shown below. You can scroll through the recommended tables on the left side of the dialog box and when you select one it will appear on the right side of the dialog box. When you are satisfied with your selection, click the OK button and your PivotTable will be inserted into a new worksheet.

You can now use the PivotTable as is or you can modify it to better suit your needs. When you click on your PivotTable, you’ll see the PivotTable Fields pop-up box, as shown in the following image.

6

To modify the PivotTable, you can simply drag and drop fields from the list into the sections near the bottom-right side of the pop-up box. In the previous example, you see the total sales for each region. You can drag and drop the Type field into the Columns section to see the totals for each product type by each region, as shown in the following image.

Create PivotTables Based on Multiple Tables As previously mentioned, it now possible in Excel® to create relationships between tables. This feature is just like the one found in Microsoft® Access®, Microsoft® SQL Server® and many other relational databases. It allows you to store data that will be repeated many times, such as customer information, in a table and link that table to another such as a product order table. Now, instead of typing the customer information into the table each time they place an order, you can simply enter their customer number into the Order table and Excel® will basically do the rest. When you have related tables, you can then create a PivotTable based on two or more of the related tables. You can have previously created the relationship between the tables, create the relationship as you create the PivotTable or connect to a database that already has the relationship between the tables established. The following example shows how to create a PivotTable based on two related tables located in a Microsoft® SQL Server®.

1. Open the worksheet where you want to put your PivotTable and then click on the Data tab.



2. Click the From Other Sources option in the Get External Data group and then click From SQL Server, as shown in the following image.

7



3. You’ll now see the Data Connection Wizard dialog box. Enter the server name and select the appropriate credentials to access the data on the server, as shown in the following image.



4. Click the Next button and you’ll be presented with an option to select the database using the drop-down box. Once you’ve selected the database, you must then check the box marked Enable selection of multiple tables, as shown in the following image.



5. Select all the tables that you wish to use to create your PivotTable by clicking the boxes next to each one. You should also make sure the Import relationships between selected tables is checked and then click the Next button.



6. You should now see the Save Data Connection File and Finish option. Enter a description of the data connection and then click the Finish button.



7. You will now see the Import Data dialog box, as shown in the following image. Select the PivotTable Report radio button, select where you want the PivotTable to go and then click the OK button.

8



8. You’ll then see a blank PivotTable in your worksheet and the PivotTable Fields pop-up box, as shown in the following image. By default, each table is expanded and you can drag and drop any of the fields from all the tables into the areas at the bottom of the pop-up box. The image below shows the tables collapsed.



9. As you begin dragging fields into the areas, you’ll see them placed on your PivotTable. Once you have all your fields in place, you are finished and can begin using your PivotTable.

9

How to Quickly Drill Down, Drill Up and Cross-drill in Your PivotTable Without Having to Go Back to Your Source Data to Identify Specific Information Slicers are easy-to-use filtering components that contain a set of buttons that enable you to quickly filter the data in a PivotTable report, without the need to open drop-down lists to find the items that you want to filter. When you use a regular PivotTable report filter to filter on multiple items, the filter indicates only that multiple items are filtered, and you have to open a drop-down list to find the filtering details. However, a slicer clearly labels the filter that is applied and provides details so that you can easily understand the data that is displayed in the filtered PivotTable report. Slicers are typically associated with the PivotTable in which they are created. However, you can also create stand-alone slicers that are referenced from Online Analytical Processing (OLAP) Cube functions, or that can be associated with any PivotTable at a later time. The following steps outline the procedure to create and use a slicer

1. Click on a cell in your PivotTable and then click the Analyze tab under PivotTable Tools.



2. Click on Insert Slicer in the Filter group and you’ll see the Insert Slicer dialog box, as shown in the following image.



3. Select the columns that you want and click the OK button. In this example, Name and Product were selected. You’ll then see the slicers, as shown in the following image.

10

You can now move the slicers to any location you wish. By default, all values are displayed and you can click on a value and only that particular value will be shown in the PivotTable. To go back to viewing all values, just click the Clear Filter icon in the upper-right side of the slicer, as shown in the following image.

When you create a PivotTable that contains rows and sub-rows, you’ll notice boxes next to the row data that indicates there are multiple levels, as shown in the following image.

The gray boxes will either have a plus (+) sign or a minus (-) sign which indicates you can expand or collapse them to drill down or up in your PivotTable. When you click directly on the box, it will expand or collapse the data to show sub-rows or to hide them. You can also accomplish the same feat by double-clicking the cell. If you select a cell containing a gray box and then click the Analyze tab under the PivotTable Tools, you can then expand or collapse all of the rows of data by using the Expand and Collapse options located in the Active Field group, as shown by the arrows in the following image.

Using the Expand and Collapse Rows options will allow you to quickly drill down and up in your data to get a better overall picture of what your data represents.

11

Sorting a PivotTable: You can reorder the summarized data in a PivotTable by sorting the table on one or more of its Column or Row fields. To sort a PivotTable, follow these steps:

1. Click the Filter button for the Column or Row field you want to sort.



2. Click either the Sort A to Z option or the Sort Z to A option at the top of the field’s dropdown list.



3. You can also select More Options to use more advanced sorting functionality, as shown below.

12

Change Your PivotTable Field Settings to Summarize the Data in Different Ways From the Default, Such as Average, Minimum, Maximum or Even Custom Settings In a PivotTable, you can change how data is summarized, as well as choose from the default, which is the sum of the data. You can also choose: 

Count: This counts the total number of data values in a row or a column in the data area. It is the default function for data that is not numeric.



Average: This is an average of all the data values in a row or a column in the data area



Max: This is the maximum value that occurs in a row or a column in the data area



Min: This is the smallest value that occurs in a row or a column in the data area



Product: This is the product of the values in a row or a column in the data area



Count Nums: Displays the number of data values that are made up of numbers



StDev: This is an estimate of the standard deviation of the data contained in a row or a column in the data area



StDevp: This is like StDev, except it is the standard deviation of all the population in the data area



Var: This is an estimate of the variance of the data contained in a row or a column in the data area



Varp: This is like Var, except it is the variance of all the population in the data area

To change the way the data is summarized:

1. In the worksheet containing the PivotTable, click a cell in the data area of the PivotTable; then click the Field Settings in the Active Field group, located under the Analyze tab in the PivotTable Tools section.



2. In the PivotTable field dialog box, shown below, you can choose how you want the data to be summarized. In the example shown below left, Average has been selected. Depending on what you want to do, there are some types of data for which you cannot change the summary function.



3. Notice the Show Values As option is set to No Calculation, as shown in the image above right. This option disables the custom calculation option. To enable the custom calculation, click the down arrow in the Show Values As section and choose an item from the list. Next, select a Base field and a Base item. Note the Base field and Base item should always be different. 13



4. When you have made your choices, click OK. In the example shown below, a custom calculation has been applied to the data area, displaying percentages based on rows.

Move or “Pivot” Your Data With a Simple Click of the Mouse The PivotTable provides so much analytical information and can be changed to give you an even closer look just by dragging information from the row headings to the column headings. This provides an easy way to look at the information a bit differently. For instance, you can switch Region and Type on the previous PivotTable simply by dragging and dropping the Region field on the Column Labels section and the Type onto the Row Labels section, as shown in the following image.

You can also move the Salesperson field into the Row labels to get a quick look at each person’s sales in each region, as shown in the following image.

14

Now you can quickly switch Region and Type to see the sales of each person by the type of product.

15

BONUS MATERIAL

New Functions Microsoft® has added many new functions to Excel®, and it would take a great deal of time to explore each and every one of them, so we’ve decided to highlight a few of the new ones that can save you time. Utilize these functions instead of trying to write your own to get the information you need. DAYS() The DAYS() function returns the number of days between two dates. This new function provides the same result as the expression EndDate – StartDate. The syntax for this function is DAYS(end_date, start_date). IFNA() The new IFNA() function works by returning a value you specify if your formula returns the #N/A error. This function is similar to the IFERROR() function but is more specific about the type of error. An example of where this might be useful is with the VLOOKUP() function that returns the #N/A error when the lookup value doesn’t exist. The syntax for this function is IFNA(value, NAvalue) where value references the formula you’re checking for errors and NAvalue is the value you want returned if value returns #N/A. SHEETS() The SHEETS() function returns the number of worksheets in the workbook containing the function. It will return the number of all worksheets, even hidden and very hidden worksheets. The syntax for this function is SHEETS([reference]) where reference can be omitted which returns the number of worksheets in the workbook containing the function or, if included, returns the number of worksheets in the named range. SHEET() Excel®’s new SHEET() function returns the worksheet number of the referenced sheet. The syntax for this function is SHEET([reference]) where reference is the name of the worksheet. If you omit reference, then it returns the number of the current worksheet. XOR() The new XOR() function is similar to the OR() function, but unlike the OR() function that returns FALSE only when all expressions are false and returns TRUE for all others, the XOR() function will only return TRUE when one of the expressions is different from all the others. You can use this function to find logical expressions where one differs. The syntax for this function is XOR(Logical1,[logical2],…).

16

ISOWEEKNUM() The new ISOWEEKNUM() function is similar to the WEEKNUM() function that returns the week number of a specified date, but it differs in that it assumes the first week of the year begins on the Monday of the week in which the first Thursday in January occurs. This is primarily for organizations that use the ISO scheme. ISO is primarily a European standard, so if you work with companies in Europe, you may need to utilize this function. The syntax for this function is ISOWEEKNUM(date). ISFORMULA() The new ISFORMULA() function is informational in nature. It returns TRUE if the referenced cell contains a formula and FALSE if not. It works on both mathematical and text-based formulas. The syntax for this function is ISFORMULA(reference). ARABIC() The new ARABIC() function is used to convert Roman numbers to Arabic. It will return an error if the referenced cell doesn’t contain a valid Roman number. For example, if the referenced cell contains XXI, then the function will return 21. While negative Roman numbers are not normally used, this function will convert them. The syntax for this function is ARABIC(text). ENCODEURL() The new ENCODEURL() function is very specialized, but as more and more people integrate information from the Web into their worksheets, this function will come into play more often. It converts non-ASCII characters to ASCII so they can be transmitted over the Internet. It is the encoding that accomplishes that feat. Suppose you had information in a worksheet in a cell that you wanted to include in a URL which would return data from the Internet back to your worksheet. You would need to use this function in order to encode the existing worksheet data to form the URL to access the remote data that will be returned to your worksheet. The syntax for this function is ENCODEURL(text). WEBSERVICE() The new WEBSERVICE() function returns data from a Web service across the Internet or from an intranet. This is the function you would use after using the ENCODEURL() function to prepare your URL for transmission. For example, suppose you had a list of cities on your worksheet. You could enter a formula in a cell next to each city that would return the current temperature in that particular city. The syntax for this function is WEBSERVICE(url).

17

How to Use the Insert Function Dialog Box to Insert Functions and to Quickly Get Help on How the Selected Function Works Excel® is packed with hundreds of built-in functions. This is what makes Excel® such a powerful application. The problem, though, is that these functions must be typed in exactly or they don’t work. Normally, you would need to have perfect recall or carry a book around with you everywhere to make use of the power of the program, but Excel® contains everything you need to get your formulas right the first time. To find the correct function to use in your formula and utilize the correct syntax:

1. Select the Formulas tab.



2. Click the Insert Function button to bring up the Insert Function dialog box as shown in the following image.



3. Select the function needed by scrolling through the list of functions or typing in the search criteria in the Search for a Function text box.



4. After you have selected the function you want, you’ll see the syntax displayed in the lower section of the dialog box and a brief description of the function. If you still have questions or concerns about how to use the function, just click on the link on the bottom left side of the dialog box to bring up help on the function you selected. The Help system has in-depth information about every function in Excel®. It also includes examples, which you can copy into your worksheet and then modify to meet your needs.

18

How to Use the Name Manager to Name a Data Range and Use It in Your Formulas to Save Time and Effort Suppose you had a data range of (B2:C7, D2:D7, F8, G9) and you wanted to make several formulas that ran different calculations on that particular range. You would have to either remember the exact cell references to the range as shown above or simply give the data range a name and then use that name in your formulas. The Name Manager found in the Defined Names group on the Formulas tab is used to create and manage named data ranges. A data range simply consists of cells in your worksheet and they do not have to be contiguous. The following steps outline the procedure to use the Name Manager to name a data range.

1. Click on the Name Manager and you’ll see the Name Manager dialog box as shown in the following image.



2. Click on the New button and you’ll see the New Name dialog box as shown in the following image.



3. Enter a name for your data range. The name should be short but descriptive so you’ll easily understand what it refers to when you see it in the Name Manager or use it in a formula.



4. The Scope setting defaults to workbook, which will be fine for most situations, so you can leave this setting as is.



5. Enter a comment about your data range. You can include a more complete description of your data range in this setting.



6. Any cells that were selected prior to launching the Name Manager will be displayed in the “Refers to” box. If you selected your data range prior to launching the Name Manager, you will be finished; if not, just click the small red arrow on the right side of the text box and select your data range. You should then click the red down arrow and you’ll be taken back to the New Name dialog box. Click the OK button and your data range will be named. 19

You can now use the name you created anywhere you would have used the column and row notation of your data range. The following example shows how to use a name (SE) in a formula that sums the values in the data range.

1. Click on the cell where you want the formula to be located.



2. Click in the Formula bar and type =SUM(SE) and then press the Enter key. When you type SE into the Formula bar, you’ll see your data range outlined. As you can see, it is a time-saver to use named data ranges in your formulas.

How to Use the Watch Window to Watch the Values of Selected Cells as You Change Values on Your Worksheet There are times, especially on very large worksheets, when the cells containing formulas are located far away from their precedent cells. You end up modifying data in the precedent cells and then you have to scroll to locate the cell containing the formula to view the results. Instead of having to move around in your worksheet to see the results of your formulas, you can watch those cells in the Watch Window toolbar. The Watch Window toolbar makes it easy to view formula results in large worksheets. The Watch Window toolbar can be moved to any location or docked on the top or bottom of the window. It keeps track of the cell properties including workbook name, worksheet name, cell location, cell value and cell formula. The following steps outline the procedure to use the Watch Window toolbar.

1. Click on the cell containing the formula that you want to watch.



2. Click on the Watch Window option in the Formula Auditing group on the Formulas tab and you’ll see the Watch Window toolbar as shown in the following image.



3. Click the Add Watch button and you’ll then see the Add Watch dialog box as shown in the image at right.



4. The cell you originally selected will be in the dialog box. You can click the Add button or select a different cell in your worksheet and then click the Add button. You can now see the properties of the selected cell displayed in the Watch Window toolbar. You can dock the toolbar by dragging it to the top or bottom of the window or you can move it to any location you wish. You can also delete a cell being watched by clicking on its entry in the Watch Window toolbar and then click the Delete Watch button. You can also close and open the Watch Window toolbar and still retain all the added cells. 20

How to Use the Evaluate Formula Dialog Box to Evaluate Each Part of Your Complex Formulas Individually to Locate and Correct Any Errors There may be a time when you have a formula that yields a value that isn’t what you expected and Excel® doesn’t report any errors. That’s when you’ll want to use the Evaluate Formula dialog box to evaluate each part of your formula so you can identify the problem and make the necessary corrections. The steps below outline the procedure to use the Evaluate Formula dialog box.

1. Click on the cell containing your formula.



2. Click on Evaluate Formula in the Formula Auditing group on the Formulas tab and this will bring up the Evaluate Formula dialog box as shown in the image at right.



3. Your formula will appear in the Evaluation window. Click on the Evaluate button to begin.



4. Your formula will then begin to be evaluated one step at a time. Clicking on the Evaluate button again will take it to the next step.



5. Continue clicking the Evaluate button and view the results of each step until you identify the problem or reach the end, which will be the result displayed in the cell on your worksheet. When you reach the final result, the Evaluate button will change to a Restart button and, if you click it, you will begin the evaluation over from the beginning.

21

How to Take Advantage of the Quick Analysis Tool to Get Instant Data Analysis Excel® now comes with the Quick Analysis tool that you can use to quickly and easily analyze your data with charts, color-coding and formulas. The Quick Analysis tool can convert your data into a chart or table in just a few simple steps. You can also use it to preview your data with conditional formatting, Sparklines or charts and make your selection with a single click of the mouse. The following steps outline the procedure to use the Quick Analysis tool.

1. Select the data that you wish to analyze and you’ll see a box in the lower right corner of the selection as indicated by the arrow in the following image.



2. Click on the box and you’ll see a pop-up box as shown in the following image.



3. Formatting is selected by default, and you can hover your mouse over any of the options and instantly see how selecting that particular option will affect your data. If you click on Charts and then mouse over the options, you’ll see charts appear based on your selection. The Totals option will insert various calculations such as sum, average, etc. in your data table. The Tables option will convert your data into a table and offers various PivotTables as well. The Sparklines option will insert different Sparklines into your data. When you’ve decided on the one you want, simply click it and it will appear. The options shown when you select the Quick Analysis tool will not always be the same. The options shown will depend on the type of data you have selected.

22

Using the Goal Seek Function to Help Determine How to Get Your Desired Result The Goal Seek function is used to determine an input value when the end result is already a known factor. In other words, you know what the desired result of a formula is, but you have no idea what value you need to insert into the formula to achieve that result. In order for this function to work, you must: • Provide a formula for the Set cell to work from • Use only one variable cell • Ask for a valid solution Using the Goal Seek function:

1. Choose the Data tab.



2. From the Data Tools group, select What-If Analysis and then Goal Seek.



3. From the Goal Seek dialog box, enter a cell reference for Set cell. This cell must contain the formula to determine the answer you are looking for. For this example, B3 contains the formula = (B1 * B2) and the known input factor for B1 is 9.



4. Next, you must fill in a value for To value. To value is the end result that you have determined. For this example, we have provided the value 900.

23



5. Now fill in By changing cell. By changing cell represents the cell where you want the unknown input value to appear. In this example, we are trying to determine what number times 9 will equal 900.



6. Click OK.



7. The Goal Seek Status box appears with your Target value and Current value. Your spreadsheet displays the unknown input value, which in this example equals 100.



8. Click OK to save your result. Click Cancel to revert back to the original values. While this example demonstrates a basic use of this tool, more complicated formulas and complex numbers can make this a very useful feature.

24

Please join us again soon! For dates, locations, complete course outlines and information on our other seminars, products and services, visit us at www.skillpath.com or www.nationalseminarstraining.com a division of the Graceland College Center for Professional Development and Lifelong Learning, Inc.

Mastering Microsoft® Excel® PivotTables V541 Webinar

5/16