Cool Excel Tips & Tricks (PACRAO 2010

)

11/2/2010

Let’s Get Started
• Why am I standing up here? • Who are you? • What am I going to teach you?

Cool Excel Tips and Tricks:

Pivot Tables, F Pi t T bl Formulas, C l l t d Fi ld l Calculated Fields, Data Merges, and More

Debi Tuttle
Lead Analyst for Student Information Systems, California Institute of Technology
2

Freeze! And Filter
• Freeze panes: keep key information in view all the time. Location: View ribbon, Window group. • Filter: narrow the results using selected criteria. Location: Home ribbon, Editing group (under Sort & Filter) or Data ribbon, Sort & Filter group.
3

Protection and Encryption
• Protect (sheet, workbook): prevent other people from messing around. Password is optional. Available on Review ribbon > Changes group. • E Encrypt ( (workbook): prevent other people kb k) h l from opening the file. Password is required. Available on Office button > Prepare > Encrypt Document.
Caveat: Excel encryption is not terribly secure. A dedicated thief could crack it easily. But it’s a reasonable way to prevent snooping.
4

Formulas
• When creating formulas, break things down into small pieces, then put everything together. • This helps you verify each individual step along the way. • Nested formulas are your friend!

Getting Functional
There are several ways to invoke functions:
• On the Formulas ribbon, the large Insert Function (fx) button will bring up a dialog box. • Also on the Formulas ribbon, commonly-used functions are grouped by area. • In any cell, typing an equals sign (=) will activate a pull-down list of recently used functions. • There is also a small Insert Function button (fx) on the aptly-named formula bar.
5 6

Debi Tuttle, Caltech (debit@caltech.edu)

1

". PROPER. =PROPER(A2) LAST_NAME field Duplicating Formulas • Drag the lower-right corner of any formula field to an adjacent cell to duplicate the formula. =LEFT(C2.". Task #1 • Step 3: Put all the pieces together using CONCATENATE. Caltech (debit@caltech. Task #1 • Step 1: Convert full middle name into a middle initial using LEFT.LEFT(C2.Cool Excel Tips & Tricks (PACRAO 2010) 11/2/2010 Manipulating Text Task #1: Turn separate all-uppercase name fields into a standard lastcomma-first-middle initial format in title case.1))) 11 12 Debi Tuttle. Excel will try to increment the cell numbers accordingly. CONCATENATE. • Click inside the function on the formula bar to display which cells are being referenced.1)) Manipulating Text. Task #1 • Step 4: Get rid of extra spaces using TRIM. 9 10 Manipulating Text.PROPER(B2). LEFT(C2.PROPER(B2)." "." ".". ".edu) 2 . Task #1 • Step 2: Convert last name and first name into title case using PROPER. =TRIM(CONCATENATE(PROPER (A2). =CONCATENATE (PROPER(A2).1) MIDDLE_NAME field Number of characters to take from the left 8 Manipulating Text. TRIM 7 Manipulating Text. Functions used: LEFT.

=LEFT(A2. 15 16 Manipulating Text. • Formula: the source data will be changing and you want the results of your formula to update automatically.) 13 Formulas or Values? • Depending on what you eventually are going to do with the data. Functions used: FIND. • Grab the lower-right corner and just drag down until you get to the bottom. IF You could also use Text To Columns (Data ribbon) but you need to be careful of compound names that contain spaces. To get around this. RIGHT. Task #2 To get the first name and middle initial we could use RIGHT or MID.Cool Excel Tips & Tricks (PACRAO 2010) 11/2/2010 Duplicating Formulas. MID. Caltech (debit@caltech. Manipulating Text.1) – 1) Manipulating Text. • Values: you are going to transfer the information to another location. Part 2 You can copy a formula all the way down the column in a couple of ways. =LEN(A2) 17 18 Debi Tuttle. do the following: • Go to the destination for the paste. LEFT.A2. we re Step 3: Use LEN to determine the total length of the name string. the data must be in a consistent format. =FIND(". Task #2 Step 1: Use FIND to determine the location of the first comma. LEN. Either way we’re going to start with: way.1) Step 2: Use LEFT to pull out the last name only. the formula will be pasted. Task #2 Task #2: Deconstruct the last-firstmiddle field we just created into its various parts. • Select the formula cell.FIND(". (Note: must be adjacent to existing data block.A2. • Select “Values” and click OK. Important! When doing this type of formula.edu) 3 . Double-click on the small square in the lower-right corner.". then right-click and select Paste right click Special. • Now the formula is gone.". you might choose to save the formulas or the ( ) results of the formula (values). 14 Paste Special • By default. This Thi gets very tiresome if you h i have thousands of rows.

23 Statistical Analysis in Excel • Caveat: Excel is a spreadsheet application. You’re actually adding y g zero to every number and converting to a true number in the process. • That being said. RIGHT(F2.LEN(F2)-2).1)-1) Or Step 4: Use MID to pull out the first name and middle initial. use IF to determine if there is a middle initial (in this case. IF(MID(F2. from the right is a space). LEFT(F2."") Tip: you can bring up the Function Arguments dialog by placing your cursor on the function name in the formula bar and pressing the Insert Function button (fx). Task #2 Step 4: Use RIGHT to pull out the first name and middle initial. Then use RIGHT to get the middle initial if it exists. SPSS.FIND(". Select “Values” and “Add” (under Operation). if the second character g p ) yes. then use LEFT and LEN to trim off the initial. or some other dedicated statistical software package. =VALUE(J2) Tip: use VALUE if the source data might change. STATA. 21 Is it Text or a Number? • Excel can store “numbers” as either text or true numbers.Cool Excel Tips & Tricks (PACRAO 2010) 11/2/2010 Manipulating Text. If y .1) . • True numbers are right-justified by default. Excel can do a lot in a pinch. use that (if you know how).1). use IF as before. Task #2 Step 5: To create the first name. If no. =MID(A2. 24 Debi Tuttle. It can do fairly sophisticated statistics. .LEN(F2)-1. Task #2 Step 6: To create the middle initial.LEN(F2) 1.LEN(A2) – FIND( FIND(". • Numbers stored as text will be leftjustified by default.A2. but if you have . =RIGHT(A2.F2) 20 Manipulating Text.".1) = " ". 22 Converting Text to Numbers • Quickest way: use Paste Special.1) = " ". =IF(MID(F2. Caltech (debit@caltech.".1)+2.LEN(F2)-1.edu) 4 . A2 1) 1) A2. LEN(A2)) 19 Manipulating Text. then return the whole name. and Excel will show a Smart Tag (little green triangle). • Another way: use the VALUE function (in the Text functions group). =IF(MID(F2.

” • To review all the named ranges you’ve defined. • The datasets must be in the same order.edu) 5 . you can use EXACT to verify the match. • Right-click and select “Name a Range.g. If you are using text fields for ordering. • The two fields need to be the same type (usually number or text). Then do one of the following: • On the Formulas tab in the Defined Names group. Naming a Range • Select the range of cells you want to name.0. a q p ) unique campus student ID). 28 Using EXACT • When you have two datasets that should contain identical records. select “Define Name” OR g p.Cool Excel Tips & Tricks (PACRAO 2010) 11/2/2010 Array Functions • Statistical functions work with arrays of data. • Step 2: Paste one dataset next to the other. • You may need to manipulate the fields to get them to be exactly the same.25) 75th Percentile: =PERCENTILE(GPA_ARRAY. click on the Name Manager on the Formulas tab. beware of uppercase vs. 30 Debi Tuttle.. • Step 4: Adjust data as necessary and perform the comparison again. Caltech (debit@caltech.0. especially if you re you’re going to perform several functions on the same array. 29 Using EXACT • Step 1: Get both datasets in the same order.75) 27 Merging Data • In order to merge two datasets. • EXACT will return TRUE or FALSE. 25 26 Basic Statistics Average/Mean: =AVERAGE(GPA_ARRAY) Median: =MEDIAN(GPA_ARRAY) Mode: =MODE(GPA_ARRAY) Standard Deviation: =STDEV(GPA_ARRAY) 25th Percentile: =PERCENTILE(GPA_ARRAY. you will need to have at least one piece of information in common (e. • Step 3: Use EXACT to compare the two columns of interest. • It’s usually easier to set up your arrays as named ranges. leaving at least one empty column between them. lowercase ordering.

set up the VLOOKUP function."No High School Found". • The data do not need to be in order.HighSchools. 33 34 =VLOOKUP(A2.FALSE)) Tip: There are several other functions that test for various conditions. place your cursor in any cell of your data. then go to the Insert ribbon > Pivot Table. Step 2: Set up a named range in your source worksheet. • Set up a mapping table on another worksheet and use it as your source. Tip: Use F3 to pull up the list of all named ranges you’ve defined. =IF(ISNA(VLOOKUP(A2. • You have to set up your data properly in order for the function to work. =IF(ISNA(VLOOKUP(A2 HighSchools 3. A = Asian).edu) 6 . 32 Using VLOOKUP Step 3: In the destination worksheet.3. THIS IS CRITICAL. Another Use For VLOOKUP • VLOOKUP can be used to “translate” coded fields into plain English (e. Creating Pivot Tables • To create a pivot table.3. The range should contain the matching field as well as any data you want to pull into the destination. They are found under More Functions > Information. make sure that the column that contains your matching field is all the way on the left.g.Cool Excel Tips & Tricks (PACRAO 2010) 11/2/2010 Using VLOOKUP • VLOOKUP is useful for merging unequal datasets and also for performing text lookups and transformations. VLOOKUP(A2. The named range in the source worksheet.HighSchools.. • Use named ranges to make things easier. Caltech (debit@caltech. W = White. y Excel will automatically select all contiguous filled cells. The number of the column (in the source worksheet) that contains the data you want to display.HighSchools. 31 Using VLOOKUP Step 1: On the source worksheet. • You could also type in any named range you’ve defined. 35 36 Debi Tuttle. Using VLOOKUP Step 4 (optional): Use IF and ISNA to handle missing values.FALSE)). • Follow the same directions as the previous example.FALSE) The column that contains the matching field. Type FALSE to ensure an exact match.

) 41 More Pivot Table Options • If there are no values in a cell. You can specify a default value for empty cells. 38 Changing Sort Order • By default. enter your value for empty cells.Cool Excel Tips & Tricks (PACRAO 2010) 11/2/2010 Arranging Pivot Tables • Excel 2007: drag and drop fields into the Field List. 40 Pivot Table Options • To give custom labels to row or column categories. g b . but leave the column you’re counting blank. Go to Display tab and check “Classic PivotTable layout. • To remove the row and column headers. 39 Field Settings • For each row or column category.edu) 7 . Caltech (debit@caltech. select “Show items with no data” to always display all values in the list. you can right-click and access “Field Settings. (Caution: this will also remove the dropdown filter buttons. • If you prefer the old way: Right-click anywhere in the pivot table and select PivotTable Options. you can either: • Right-click in the data area of the table. Tip: If you want to display a value that doesn’t exist in your data set at all. select Summarize Data By. and then select your desired summarization. You can set a manual order by clicking and dragging the item name. • Select the item name and then move the cursor carefully over the border of the cell until the it changes to a fourdirection arrow.” • On the Layout & Format tab. type it at the bottom of your dataset.” But you will not be able to take advantage of some of the newer pivot table features in this mode. g Right-click and select Pivot Table Options. or • In the Field List. by default the cell will be blank. explore what other Pivot Table Options are available here. • When you have time. You may need to adjust the data source to include the new line. access the dropdown list of the appropriate field name. Then click and drag to the desired location. items will be ordered alphabetically. select Value Field Settings. click the Field Headers button in the Show/Hide group. On the Layout and Format tab. 42 Debi Tuttle. select the cell and type text in the formula bar. 37 Changing the Summarization To change the pivot table summarization being performed. on the Pivot Table Options bar. not the pivot table. and then select your desired summarization.

you can stack them vertically by moving the “∑ Values” item from Column Labels to Row Labels. the column names and data types must be the same between the two sources. • Sort the list on the random number column. 47 Random Sampling • Use the RAND function to assign everyone a random number between zero and one. then change the d h h data source (Pi (Pivot T bl Table Options tab > Change Data Source). • RAND will recalculate when you sort. Caltech (debit@caltech. y ) text) or by Value ( yp Use the dropdown menu on the Row or Column labels and select Label Filters or Value Filters. 45 Calculated Fields • Calculated fields operate on summarized pivot table data. bottom) Report layouts (compact.Cool Excel Tips & Tricks (PACRAO 2010) 11/2/2010 Pivot Table Design On the Pivot Table Design tab. The PivotChart will update as you modify the underlying PivotTable. Tip: When you have multiple items in the Values area. • Obviously. 46 Filter & Sort in Pivot Tables • The regular Excel filter buttons will not work inside pivot tables. 48 Debi Tuttle. Pivot Table Options > Groups. • Right-click on any column in the Values area to access the Sort menu. Pivot Table Options > PivotChart. you have many choices: • • • • • PivotTable Style Banded rows and columns Blank lines between items Subtotal location (top vs.edu) 8 . p g g • Use Groups to organize categories. You can filter pivot tables by Label (typically ) y (typically numbers). • To create a calculated field: PivotTable Options ribbon > Formulas > Calculated Field. outline. you can copy the table and paste it somewhere else (Pivot Table Options tab > Select > Entire PivotTable). • Take how ever many rows you need for your sample from the top. • Use a PivotChart to get a visual representation of your data. or tabular) • Grand Totals 43 Re-using a Pivot Table • If you want to re-use a pivot table. but that doesn’t matter. 44 Other Pivot Table Tricks • Display percentages and differences by using Value Field Settings > Show values as.

• Instructions and examples: http://www. either: date wizard • Change the file extension to . Caltech (debit@caltech. 49 50 Customize Your Workspace • The Quick Access Toolbar: Office Button > Excel Options > Customize Learning More about Excel • • • • Search/browse the function list Use Excel Help Buy a book Search online S h li 51 52 “No Question Time! crime is so great as daring to excel. then open the document. This will open the file in a new document. I hope you learned something useful! Debi Tuttle debit@caltech.TXT.edu 53 54 Debi Tuttle. This will insert the file into your current workbook.CSV extension. To get the wizard. • Go the Data ribbon and click the “From Text” button. Excel does not invoke the text import wizard.” -.edu) 9 .aspx Text Import Wizard When importing a comma-delimited text file with a .Winston Churchill Thank you for your time.cpearson.Cool Excel Tips & Tricks (PACRAO 2010) 11/2/2010 Calculate Age • DATEDIF is a very useful but undocumented function that calculates time intervals between two dates.com/excel/datedif. • You will need to type it because it isn’t available from the function list (!). and you can’t control if columns are set as text or number or date.