Unit 3.3: Advanced Formulas & Data Management

--:-- --
↓ Scroll for more

Unit 3.3

Advanced Formulas & Data

PRC 110: Software Skills Practicum

📖 Read the full notes: MS Excel: Data Management Basics · MS Excel: Linking Workbooks and Worksheets

Learning Objectives

  • Use IF (and nested IF).
  • Use VLOOKUP / INDEX-MATCH.
  • Sort and Filter data.

The IF Function

=IF(Condition, Value_if_True, Value_if_False)

=IF(B2>=45,"Pass","Fail")

Nested: =IF(D2>25000,"High",IF(D2>10000,"Medium","Low"))

Comparison Operators

= equal · <> not equal · > < · >= <=. Each test returns TRUE or FALSE.

Quick poll: A2 = 45 and B2 = Pokhara. Predict:

  • =A2>45 → FALSE (45 is not greater than 45)
  • =IF(A2<>50,"Retest","OK") → Retest
  • =IF(B2="pokhara","West","Other") → West: = ignores upper/lower case
  • =IF(A2>=50,"Pass") → FALSE: with no third argument, IF shows FALSE

Rule: text goes inside "double quotes"; numbers and cell references do not.

IF this way, THEN that place

A trail signboard in Shivapuri Nagarjun National Park, Nepal

Check: IF Logic

Ask a student or group first — then click to check.

Hands-on: IF on Sales Data

Open sales_data_large.csv and Save As Excel Workbook (.xlsx) first. G = Sales Amount, rows 2–241.

  1. H1 Target Met?, H2 =IF(G2>5000,"Yes","No"), double-click the fill handle. → H2 Yes (12,632)
  2. In L2: =COUNTIF(H2:H241,"Yes") → 196 of 240
  3. I1 Band, I2 =IF(G2>25000,"High",IF(G2>10000,"Medium","Low")), fill down. → I2 Medium; I8 Low (1,299)
  4. In L3: =COUNTIF(I2:I241,"High") → 108

Discuss: 196 of 240 sales beat a 5,000 target. Is the target useful? What would you set?

Two Conditions: AND, OR, IFS

  • =IF(AND(B2="West",G2>50000),"Star",""): both must be true. 23 rows get "Star".
  • =IF(OR(B2="West",G2>100000),"Check",""): either one is enough. 103 rows.
  • =IFS(G2>25000,"High",G2>10000,"Medium",TRUE,"Low") gives the same bands as the nested IF and is easier to read (Excel 2019, 2021, 2024 and Microsoft 365).

Order matters: test the highest threshold first. If G2>10000 came first, a 2,08,852 sale would be labelled "Medium".

Worked Example: COUNTIF and SUMIF

QuestionFormulaResult
How many Laptop sales?=COUNTIF(C2:C241,"Laptop")32
Sales above 1,00,000?=COUNTIF(G2:G241,">100000")54
West region revenue=SUMIF(B2:B241,"West",G2:G241)92,25,197
West Laptop revenue=SUMIFS(G2:G241,B2:B241,"West",C2:C241,"Laptop")67,23,705

Trap: SUMIF puts the sum range last; SUMIFS puts it first.

Your turn: total revenue for salesperson Bikash. → =SUMIF(D2:D241,"Bikash",G2:G241) = 52,17,893

How many laptops sold? COUNTIF. How much money? SUMIF

Electronics store aisles

VLOOKUP

=VLOOKUP(Lookup_Value, Table_Array, Col_Index, FALSE)

  • Use FALSE / 0 for exact match on names/IDs.
  • INDEX + MATCH is more flexible when columns move.

Look up the key, read across

A wooden library card catalog

🎬 Watch: VLOOKUP, One Argument at a Time

Hands-on: VLOOKUP a Category

  1. Add a sheet (the + by the sheet tabs) and rename it Lookup. A1 Product, B1 Category.
  2. A2:B9: Laptop, Monitor → Computer; Keyboard, Mouse, USB Hub, Webcam, Headphones → Accessory; Notebook → Stationery.
  3. Back on the data sheet: J1 Category, J2 =VLOOKUP(C2,Lookup!$A$2:$B$9,2,FALSE), fill down. → J2 Accessory (USB Hub); J3 Computer (Monitor)
  4. On Lookup, change Webcam to Web Cam. → every Webcam row shows #N/A. Press Ctrl+Z to undo.

Why $A$2:$B$9? So the table stays put when you fill the formula down (Unit 3.2).

When a Lookup Fails: #N/A

Usual causes

  • Spelling differs: "Web Cam" vs "Webcam"
  • Hidden extra space: "Laptop "
  • Number stored as text: 101 vs "101"
  • The value isn't in the table's first column

Fixes

  • =TRIM(C2) strips extra spaces
  • =IFERROR(VLOOKUP(…),"Not found")

Discuss: should you always wrap lookups in IFERROR? → No. It also hides real mistakes, so show a clear message and check the "Not found" rows.

Three Ways to Look Up

VLOOKUPINDEX + MATCHXLOOKUP
Available inAll versionsAll versionsExcel 2021, 2024, Microsoft 365
Return a column to the left?NoYesYes
Inserting a column inside the tableCan return the wrong columnSafeSafe
  • =INDEX(Lookup!$B$2:$B$9,MATCH(C2,Lookup!$A$2:$A$9,0))
  • =XLOOKUP(C2,Lookup!$A$2:$A$9,Lookup!$B$2:$B$9,"Not found"): exact match by default

Poll: which one would you use in a lab that still runs Excel 2016? → VLOOKUP or INDEX + MATCH

Sorting & Filtering

Sort

Data > Sort — single or multi-level.

Filter

Data > Filter — show only matching rows.

Hands-on: Sort and Filter

  1. Click any cell in the data and press Ctrl+T → tick "My table has headers" → OK. → filter arrows appear on every header
  2. Sales Amount arrow → Sort Largest to Smallest. → top row 13,50,324 (Laptop, East, Chhaya)
  3. Data → Sort: Region A→Z, Add Level Sales Amount Largest→Smallest. → East first; first West row is 11,75,300 (Elina)
  4. Filter Region = East, then Product = Laptop. → 5 rows. Clear with Data → Clear.
  5. View → Freeze Panes → Freeze Top Row. → headers stay visible as you scroll

Never sort one column alone: the rows get scrambled. Sort the whole table.

Sorting at scale

A high-speed mail sorting machine

Check: Lookup & Filter

Ask a student or group first — then click to check.

Real Case: The Missing 15,841

  • England, Oct 2020: 15,841 positive COVID-19 results from 25 Sep to 2 Oct were left out of the daily figures.
  • Cause: lab CSV files were merged into templates in the old .xls format, which holds only 65,536 rows. Extra rows were cut off silently.
  • An .xlsx sheet holds 1,048,576 rows. Contact tracing for the missing cases started days late.

Pair discussion: which simple checks would have caught it? → compare row counts before and after (=COUNTA()) · check that totals look reasonable · use the right file format, or a database for big data

🎬 Watch: The Template That Ran Out of Rows

Each missed row was a person waiting for a call

A laboratory worker processing samples (US Navy Medicine, April 2020)

Practicum 3.3

Data analysis

Use sales_data_large.csv:

  1. IF “Target Met?” if Sales > 5000.
  2. VLOOKUP / INDEX-MATCH a product.
  3. Filter a region; sort by Sales Amount.

Credits

  • Image: Trail signboard, Sano Deurali, Shivapuri — Krishna k. sahh, CC0, via Wikimedia Commons (source)
  • Image: Electronics store, 2016 — Own work, Public domain, via Wikimedia Commons (source)
  • Image: Card catalog, Indiana State Library — TBurmeister (WMF), CC BY-SA 4.0, via Wikimedia Commons (source)
  • Image: BLW high-speed sorting machine — Mike Peel, CC BY-SA 2.0 uk, via Wikimedia Commons (source)
  • Image: Laboratory worker (US Navy Medicine) — Navy Medicine from Washington, DC, USA, Public domain, via Wikimedia Commons (source)
  • Video: VLOOKUP in Excel — Kevin Stratvert, YouTube xIynD1gFOLo, 1:08–2:27
  • Video: This Excel Mistake Lost 16,000 COVID Cases (I Recreated It) — The Spreadsheet Files, YouTube 6iFtJZH1gp0, 0:43–1:21
  • Sample data: sales_data_large.csv — PRC 110 sample pack

Thank You

Questions? Keep your workbook with the Lookup sheet; Unit 3.4 builds on it.

PRC 110: Software Skills Practicum · Unit 3.3