Rana Maninder Singh
Lesson 4 of 8Excel & Spreadsheets

Advanced Functions

Lesson opener

In one line: Logic (IF, AND, OR), multi-criteria aggregates, error handling, SUMPRODUCT, dynamic arrays, and INDEX/MATCH.

Why it matters: This shows up at work when you need to logic (IF, AND, OR), multi-criteria aggregates, error handling, SUMPRODUCT, dynamic arrays, and INDEX/MATCH..

Before this lesson: Basic functions

Before you start

ResourceLink
PreviousBasic functions
NextLookups


What you will learn

Logic (IF, AND, OR), multi-criteria aggregates, error handling, SUMPRODUCT, dynamic arrays, and INDEX/MATCH.

Excel vs Python vs SQL — same task, three tools
Excel vs Python vs SQL — same task, three tools

IF and nested IF

IF

1. THE PROBLEM

You cannot type High or Standard on 500 order rows by hand — one typo and your report is wrong.

2. PLAIN ENGLISH VERSION

Ask Excel one yes-or-no question per row. If yes, show one answer. If no, show the other.

3. WHEN TO USE IT

Sales rows where revenue above a dollar threshold should flag as High for the fulfilment team.

4. THE FORMULA

=IF(SalesAmount>2000,"High","Standard")

5. BREAKDOWN

6. WHAT YOU WILL SEE

High or Standard in the cell — a label you can filter or sort.

Try it yourself

Imagine this data (press Ctrl+T to make it a table named Orders):

OrderIDSalesAmount
O0012400
O002800
O0032100

Click C2, header Priority in C1. Type:

=IF(SalesAmount>2000,"High","Standard")

Press Enter. Row 2 shows High. Copy down. Row 3 shows Standard. Row 4 shows High.


Nested IF

1. THE PROBLEM

A single IF only gives two buckets — Many, Some, and Few need three.

2. PLAIN ENGLISH VERSION

Run a second IF inside the "no" branch when the first answer is not enough.

3. WHEN TO USE IT

Support ticket counts where you need three bands, not just over/under one number.

4. THE FORMULA

=IF(SupportTickets>5,"Many tickets",IF(SupportTickets>2,"Some","Few"))

5. BREAKDOWN

6. WHAT YOU WILL SEE

Many tickets, Some, or Few depending on the ticket count on that row.

Try it yourself

CustomerNameSupportTickets
Acme Corp7
Beta Ltd3
Gamma Inc1

In C2 (header Volume):

=IF(SupportTickets>5,"Many tickets",IF(SupportTickets>2,"Some","Few"))

You see Many tickets, Some, Few on the three rows.


IFS

1. THE PROBLEM

Nested IFs stack up and become impossible to read after three bands.

2. PLAIN ENGLISH VERSION

Line up several tests in one function — first match wins.

3. WHEN TO USE IT

Grading products or reps into A, B, or C tiers from revenue numbers.

4. THE FORMULA

=IFS(SalesAmount>=2000,"A",SalesAmount>=1000,"B",TRUE,"C")

5. BREAKDOWN

6. WHAT YOU WILL SEE

A single letter grade — A, B, or C.

Try it yourself

ProductNameSalesAmount
Notebook2400
Pen800
Stapler1500

In C2 (header Grade):

=IFS(SalesAmount>=2000,"A",SalesAmount>=1000,"B",TRUE,"C")

You see A, C, B.


SWITCH

1. THE PROBLEM

IF keeps asking true/false questions when you already know the exact codes in the column.

2. PLAIN ENGLISH VERSION

Match this cell's value against a list of known options and return the matching label.

3. WHEN TO USE IT

CRM tier codes like Gold, Silver, Bronze that need readable labels in a management report.

4. THE FORMULA

=SWITCH(CustomerTier,"Gold","Premium","Silver","Standard","Bronze","Entry","Other")

5. BREAKDOWN

6. WHAT YOU WILL SEE

A readable label — Premium, Standard, Entry, or Other.

Try it yourself

CustomerNameCustomerTier
JaneGold
BobSilver
PatBronze

In C2 (header DisplayTier):

=SWITCH(CustomerTier,"Gold","Premium","Silver","Standard","Bronze","Entry","Other")

You see Premium, Standard, Entry.


AND, OR (compound conditions)

AND inside IF

1. THE PROBLEM

Strong revenue alone does not mean a healthy account if support tickets are through the roof.

2. PLAIN ENGLISH VERSION

Only say yes when every condition is true at the same time.

3. WHEN TO USE IT

Flagging accounts that have high revenue and low ticket volume together.

4. THE FORMULA

=IF(AND(SalesAmount>1000,SupportTickets<3),"Healthy","Watch")

5. BREAKDOWN

6. WHAT YOU WILL SEE

Healthy or Watch — a quick risk flag for your account review.

Try it yourself

CustomerNameSalesAmountSupportTickets
Acme15001
Beta15008
Gamma4001

In D2 (header Status):

=IF(AND(SalesAmount>1000,SupportTickets<3),"Healthy","Watch")

Acme → Healthy. Beta → Watch (too many tickets). Gamma → Watch (low revenue).


OR inside IF

1. THE PROBLEM

Two separate IF formulas for Gold and Platinum customers means double the work.

2. PLAIN ENGLISH VERSION

Say yes when at least one condition is true — you do not need all of them.

3. WHEN TO USE IT

Gold and Platinum customers both get VIP treatment in a campaign email list.

4. THE FORMULA

=IF(OR(CustomerTier="Gold",CustomerTier="Platinum"),"VIP","Standard")

5. BREAKDOWN

6. WHAT YOU WILL SEE

VIP or Standard on each row.

Try it yourself

CustomerNameCustomerTier
JaneGold
BobSilver
PatPlatinum

In C2 (header CampaignTag):

=IF(OR(CustomerTier="Gold",CustomerTier="Platinum"),"VIP","Standard")

Jane and Pat → VIP. Bob → Standard.

Use AND and OR inside IF, IFS, or as criteria in SUMIFS.


IFERROR and IFNA (lookups & division)

IFERROR

1. THE PROBLEM

Dividing by a blank target blows up the sheet with #DIV/0! and scares people at the meeting.

2. PLAIN ENGLISH VERSION

Try the math first. If Excel hits any error, show friendly text instead.

3. WHEN TO USE IT

Monthly actual-vs-target report where some targets are still blank.

4. THE FORMULA

=IFERROR(SalesAmount/TargetRevenue,"n/a")

5. BREAKDOWN

6. WHAT YOU WILL SEE

A number like 1.2 when the math works, or n/a when it cannot divide.

Try it yourself

ProductNameSalesAmountTargetRevenue
Notebook24002000
Pen8000
Stapler1500

In D2 (header VsTarget):

=IFERROR(SalesAmount/TargetRevenue,"n/a")

Notebook → 1.2. Pen → n/a (divide by zero). Stapler → n/a (blank target).


IFNA

1. THE PROBLEM

IFERROR hides every error — including typos you actually need to see.

2. PLAIN ENGLISH VERSION

Catch only missing-match errors from lookups. Let other errors show through.

3. WHEN TO USE IT

Right after a lookup when a missing customer ID is normal but bad math should still scream.

4. THE FORMULA

=IFNA(XLOOKUP(CustomerID,Customers[CustomerID],Customers[Segment]),"Unknown")

5. BREAKDOWN

6. WHAT YOU WILL SEE

A segment name like Gold, or Unknown when the ID is not in the master table.

Try it yourself

Master table Customers on the same sheet (rows 8–10):

CustomerIDSegment
C001Gold
C002Silver

Orders table starting at A1:

CustomerIDSegment
C001
C999

In B2:

=IFNA(XLOOKUP(CustomerID,Customers[CustomerID],Customers[Segment]),"Unknown")

C001 → Gold. C999 → Unknown.

FunctionCatches
IFERRORAny error (#DIV/0!, #N/A, …)
IFNAOnly #N/A (often cleaner after lookups)

SUMIFS / COUNTIFS / AVERAGEIFS

1. THE PROBLEM

Filtering the sheet, copying Gold rows, and summing by hand breaks the moment someone adds a row.

2. PLAIN ENGLISH VERSION

Add, count, or average only rows where every condition you list is true.

3. WHEN TO USE IT

Month-end segment report — Gold revenue, Silver active count, and average spend for long-tenure customers in one pass.

4. THE FORMULA

=SUMIFS(Customers[TotalRevenue],Customers[Segment],"Gold")
=COUNTIFS(Customers[Segment],"Silver",Customers[Churned],0)
=AVERAGEIFS(Customers[MonthlySpend],Customers[TenureMonths],">24")

5. BREAKDOWN

6. WHAT YOU WILL SEE

One number per formula — total dollars, a count, or an average.

Try it yourself

CustomerNameSegmentTotalRevenueChurnedMonthlySpendTenureMonths
AcmeGold5000020030
BetaGold3000015012
GammaSilver2000010036
DeltaSilver100018040

On a blank area, type:

=SUMIFS(Customers[TotalRevenue],Customers[Segment],"Gold")

You see 8000 (5000 + 3000).

=COUNTIFS(Customers[Segment],"Silver",Customers[Churned],0)

You see 1 (only Gamma — Delta churned).

Each criteria pair is AND logic. For OR across segments, add two SUMIFS together or use SUMPRODUCT.


SUMPRODUCT (weighted totals & flexible logic)

Gold revenue only

1. THE PROBLEM

SUMIFS works great until you need custom row-by-row logic that does not fit its pattern.

2. PLAIN ENGLISH VERSION

Turn TRUE/FALSE tests into 1s and 0s, multiply row by row, then add everything up.

3. WHEN TO USE IT

Gold-only revenue in one cell when your condition is too custom for SUMIFS.

4. THE FORMULA

=SUMPRODUCT((Customers[Segment]="Gold")*Customers[TotalRevenue])

5. BREAKDOWN

6. WHAT YOU WILL SEE

Total Gold revenue as one number — same as SUMIFS for this case, but more flexible for harder rules.

Try it yourself

Use the Customers table from the SUMIFS example above. Type:

=SUMPRODUCT((Customers[Segment]="Gold")*Customers[TotalRevenue])

You see 8000.


Weighted average

1. THE PROBLEM

A plain AVERAGE treats a customer with 1 order the same as one with 100 — that skews the number.

2. PLAIN ENGLISH VERSION

Multiply each row's weight by its value, add them up, divide by total weight.

3. WHEN TO USE IT

Average deal size where high-order customers should count more.

4. THE FORMULA

=SUMPRODUCT(Customers[TotalOrders],Customers[MonthlySpend])/SUM(Customers[TotalOrders])

5. BREAKDOWN

6. WHAT YOU WILL SEE

One average number — pulled toward customers with more orders.

Try it yourself

CustomerNameTotalOrdersMonthlySpend
Acme10200
Beta2100
=SUMPRODUCT(Customers[TotalOrders],Customers[MonthlySpend])/SUM(Customers[TotalOrders])

You see 183.33 — closer to Acme than a plain average of 150.


SUBTOTAL (respects filters)

1. THE PROBLEM

SUM adds hidden filtered rows — the total at the bottom does not match what the manager sees on screen.

2. PLAIN ENGLISH VERSION

Sum only the rows that are still visible after someone applies a filter.

3. WHEN TO USE IT

Interactive customer list where the manager filters to one region and needs the revenue total to follow.

4. THE FORMULA

=SUBTOTAL(109,Customers[TotalRevenue])

5. BREAKDOWN

6. WHAT YOU WILL SEE

A total that shrinks or grows when you filter — always matching visible rows.

Try it yourself

Use the Customers table from SUMIFS. Put the formula under the data. Filter Segment to Gold only. The SUBTOTAL shows 8000, not the full-table sum.


Dynamic arrays (Excel 365 / 2021)

UNIQUE

1. THE PROBLEM

Copy-pasting distinct segment names into a dropdown goes stale the moment a new segment appears.

2. PLAIN ENGLISH VERSION

List each distinct value once — Excel spills the list into cells below if needed.

3. WHEN TO USE IT

Dropdown source list for a dashboard that must stay in sync with live data.

4. THE FORMULA

=UNIQUE(Customers[Segment])

5. BREAKDOWN

6. WHAT YOU WILL SEE

A vertical list — Gold, Silver, Bronze — one entry each, no repeats.

Try it yourself

Segment
Gold
Silver
Gold
Bronze

In E1:

=UNIQUE(Customers[Segment])

You see Gold, Silver, Bronze spilled down three cells.


FILTER

1. THE PROBLEM

You only want active customer IDs but hiding rows with a filter is manual and easy to forget.

2. PLAIN ENGLISH VERSION

Return a new list of values where your condition is true.

3. WHEN TO USE IT

Live list of customer IDs where Churned = 0 for a mail-merge or audit.

4. THE FORMULA

=FILTER(Customers[CustomerID],Customers[Churned]=0)

5. BREAKDOWN

6. WHAT YOU WILL SEE

A spilled list of IDs — only the active ones.

Try it yourself

CustomerIDChurned
C0010
C0021
C0030

In D1:

=FILTER(Customers[CustomerID],Customers[Churned]=0)

You see C001 and C003 spilled down.


SORT with UNIQUE

1. THE PROBLEM

UNIQUE gives you segments in random table order — not good for a sorted dropdown.

2. PLAIN ENGLISH VERSION

Take the distinct list and alphabetize it.

3. WHEN TO USE IT

Segment picker on a report where options should read A-to-Z.

4. THE FORMULA

=SORT(UNIQUE(Customers[Segment]))

5. BREAKDOWN

6. WHAT YOU WILL SEE

Bronze, Gold, Silver in alphabetical order.

Try it yourself

Use the Segment column from the UNIQUE example. In F1:

=SORT(UNIQUE(Customers[Segment]))

You see Bronze, Gold, Silver top to bottom.


RANK

1. THE PROBLEM

Sorting the whole revenue column just to find who is #1 wastes time and breaks other views.

2. PLAIN ENGLISH VERSION

Tell me where this one number sits in the list — biggest or smallest.

3. WHEN TO USE IT

Leaderboard column in a rep performance sheet that updates when revenue changes.

4. THE FORMULA

=RANK.EQ(SalesAmount,Customers[TotalRevenue],0)

5. BREAKDOWN

6. WHAT YOU WILL SEE

A number like 1, 2, 3 — rank position in the list.

Try it yourself

CustomerNameTotalRevenue
Acme5000
Beta3000
Gamma5000

In C2 for Acme's row:

=RANK.EQ(TotalRevenue,Customers[TotalRevenue],0)

Acme and Gamma both show 1. Beta shows 3.


MATCH and INDEX

INDEX with MATCH (flexible lookup)

1. THE PROBLEM

VLOOKUP only looks right and needs the key on the left — your table layout may not cooperate.

2. PLAIN ENGLISH VERSION

MATCH finds the row number. INDEX picks the value from that row.

3. WHEN TO USE IT

You know a CustomerID and need TotalRevenue from a wide customer table.

4. THE FORMULA

=INDEX(Customers[TotalRevenue],MATCH("C0042",Customers[CustomerID],0))

5. BREAKDOWN

6. WHAT YOU WILL SEE

One number — the revenue for customer C0042.

Try it yourself

CustomerIDTotalRevenue
C00401000
C00423500
C00442000
=INDEX(Customers[TotalRevenue],MATCH("C0042",Customers[CustomerID],0))

You see 3500.


INDEX/MATCH — top customer segment

1. THE PROBLEM

Finding which segment owns the highest revenue means sorting or scanning by eye.

2. PLAIN ENGLISH VERSION

Find the biggest revenue, locate its row, pull the segment from that same row.

3. WHEN TO USE IT

Executive summary flagging which tier the top customer belongs to.

4. THE FORMULA

=INDEX(Customers[Segment],MATCH(MAX(Customers[TotalRevenue]),Customers[TotalRevenue],0))

5. BREAKDOWN

6. WHAT YOU WILL SEE

A tier name like Gold — the segment of your top revenue customer.

Try it yourself

CustomerNameSegmentTotalRevenue
AcmeGold5000
BetaSilver3000
=INDEX(Customers[Segment],MATCH(MAX(Customers[TotalRevenue]),Customers[TotalRevenue],0))

You see Gold.


Two-way INDEX/MATCH

1. THE PROBLEM

Your metric sits at a row label and a column label — one-direction lookup cannot reach it.

2. PLAIN ENGLISH VERSION

Find the row number and column number, then grab the value at that intersection.

3. WHEN TO USE IT

Quarterly revenue grid by segment — a small matrix, not a long flat table.

4. THE FORMULA

=INDEX(RevenueGrid,MATCH("Gold",SegmentLabels,0),MATCH("Q1",QuarterLabels,0))

5. BREAKDOWN

6. WHAT YOU WILL SEE

One number — Gold segment revenue in Q1.

Try it yourself

Labels and grid (type exactly):

Q1Q2
Gold1000012000
Silver50006000

Name the 2×2 number block RevenueGrid, row labels SegmentLabels, column headers QuarterLabels. Type:

=INDEX(RevenueGrid,MATCH("Gold",SegmentLabels,0),MATCH("Q1",QuarterLabels,0))

You see 10000.


Essential commands

Command / actionWhat it does
=IF / =IFS / =SWITCHConditional or multi-branch values.
=AND / =ORCombine TRUE/FALSE tests.
=IFERROR / =IFNAReplace errors with friendly text.
=SUMIFS / =COUNTIFS / =AVERAGEIFSAggregate with one or more AND criteria.
=SUMPRODUCTMultiply arrays then sum; flexible conditions.
=SUBTOTAL(109, range)SUM that ignores filtered-out rows.
=UNIQUE / =FILTER / =SORTDynamic array lists (Microsoft 365).
=RANK.EQRank a value in a list.
=MATCH(lookup, range, 0)Position of exact match in range.
=INDEX(range, row, [col])Value at row/column in range.
Home → Conditional FormattingHighlight cells by rules or color scales.

Practice — no download needed

Open a blank Excel sheet. Follow these steps exactly:

Step 1: Type this table starting at A1 (press Ctrl+T, name it Customers):

CustomerNameSegmentTotalRevenueSupportTicketsChurned
Acme CorpGold500010
Beta LtdSilver200040
Gamma IncGold300020
Delta CoBronze80061
Echo LLCSilver150010

Step 2: On G1, type GoldRevenue. On G2, type:

=SUMIFS(Customers[TotalRevenue],Customers[Segment],"Gold")

Press Enter. You should see 8000.

On H1, type TopSegment. On H2, type:

=INDEX(Customers[Segment],MATCH(MAX(Customers[TotalRevenue]),Customers[TotalRevenue],0))

You should see Gold.

Step 3: What do you see?

G2 → 8000 (Acme + Gamma). H2 → Gold (Acme has the max revenue).

If you see #NAME?: check the table is named Customers and column headers match exactly.

Step 4: Select C2:C6 (TotalRevenue). Click Home → Conditional Formatting → Color Scales. Rows with higher revenue turn greener. Filter Segment to Gold — add =SUBTOTAL(109,Customers[TotalRevenue]) below and watch it show 8000, not the full column sum.

Challenge (optional): In I2, flag Healthy only when TotalRevenue > 2000 and SupportTickets < 3. How many Healthy rows do you get?

Checklist

  • [ ] Can you label each row High or Standard using IF on a sales threshold?
  • [ ] Can you sum Gold revenue with SUMIFS without filtering and copying by hand?
  • [ ] Can you wrap a division in IFERROR so blank targets show n/a instead of #DIV/0!?
  • [ ] Can you pull one customer's revenue using INDEX and MATCH?
  • [ ] Can you make revenue cells turn greener as values rise using conditional formatting?
  • [ ] Can you build this practice sheet from scratch without downloading a file?