Courses Learn Blog Contact
Get Started →
Lesson 11

Week 3, Live 1: How Formulas Work, the Basic Functions, and IF, IFS, AND, OR

How Excel reads a formula, SUM to MAX on real business questions, and labelling data with conditions.

Webbo3 Data Analytics Cohort 2: Excel Track 23 min read Free

Webbo3 Data Analytics · Cohort 2 · Excel Track · Week 3, Live 1

How Formulas Work, the Basic Functions, and IF, IFS, AND, OR

This week the data starts answering questions. First you learn exactly how Excel reads a formula and build the Revenue column the workbook is missing, then the six functions every report uses, then how to make Excel label each sale by a rule.

By the end of this class you can

  • Explain the parts of a formula and the order Excel calculates them in
  • Build a Revenue column, and see what a blank quantity does to it
  • Use relative and absolute ($) references, and see what goes wrong without $
  • Calculate business totals with SUM, AVERAGE, COUNT, COUNTA, MIN and MAX
  • Label sales with IF and nested IF, then more cleanly with IFS
  • Test two conditions at once with AND and OR

Start from your cleaned workbook from Week 2, or from TechPlug_Sales_Data_Cleaned.csv in the downloads: 1,050 sales in columns A to L, names clean, Quantity still blank on 25 sales. Notice something missing: there is a Quantity and a Unit_Price, but no column that says what each sale was worth. That is the first thing we build.

1. How Excel Reads a Formula

Definition

A formula is an instruction in a cell that tells Excel to calculate something. It always starts with an equals sign. The cell shows the answer; the formula bar shows the instruction. When any cell the formula uses changes, the answer updates by itself.

Real-Life Scenario

A calculator gives you an answer and forgets how it got there. A recipe card keeps the method: change "4 people" to "6 people" and every quantity is recalculated. A typed number is a calculator answer. A formula is a recipe card.

The Parts of a Formula

PartExampleWhat it is
Equals sign=Tells Excel this is a formula, not text
Cell referenceF2, M2:M1051Use whatever is in that cell or range
Operator+ - * / ^Add, subtract, multiply, divide, raise to a power
FunctionSUM( )A built-in calculation with a name, taking inputs in brackets
Constant1000000, "High"A fixed value typed into the formula. Text always goes in double quotes
Comparison> < = >= <= <>Asks a question that is TRUE or FALSE. <> means "not equal to"

Order of Operations

Excel follows the same order you learnt in school maths (BODMAS): brackets first, then powers, then multiply and divide, then add and subtract. Predict these two before you look:

What these formulas doWe want to see the same three numbers give two different answers depending on the brackets.
XTechPlug_Sales_Workbook.xlsx - Excel
After Enter
O2
fx
=2+3*4
NO
1TypedResult
22 + 3 x 414
3(2 + 3) x 420
Cleaning ProcessSales DataProduct CatalogueStaff Directory
What is typed in each cell
O2 =2+3*4
O3 =(2+3)*4

Without brackets, 3 x 4 happens first and 2 is added after: 14. With brackets, 2 + 3 happens first: 20. When in doubt, add brackets. They never hurt, and they make your intention obvious to the next reader.

Your First Real Formula: Revenue

What is a sale worth? Its Quantity times its Unit_Price. In M1 type Revenue, in M2 type the formula, press Enter, and double-click the fill handle:

What this formula doesWe want the value of every sale: the number of units multiplied by the price of one unit.
XTechPlug_Sales_Workbook.xlsx - Excel
After Enter and Fill Down
M2
fx
=F2*G2
A⋯FG⋯M
1Transaction_IDQuantityUnit_PriceRevenue
2TP-08923380,0001,140,000
3TP-0785475,000300,000
⋮⋮⋮⋮⋮
22TP-0511285,0000
⋮⋮⋮⋮⋮
27TP-045410285,0002,850,000
⋮⋮⋮⋮⋮
32TP-05286699,0004,194,000
33TP-0379285,0000
⋮⋮⋮⋮⋮
42TP-03589699,0006,291,000
⋮⋮⋮⋮⋮
46TP-006710450,0004,500,000
Filled down from M2 to M1051: 1,050 rows. Rows 2, 3, 22, 27, 32, 33, 42, 46 shown.
Cleaning ProcessSales DataProduct CatalogueStaff Directory

Every row has a value. Look at rows 22 and 33: Quantity is blank, and Revenue says 0. In a calculation Excel treats an empty cell as 0, and 0 times any price is 0. Those sales did happen; we just do not know how many units were sold. Saying they were worth nothing is wrong, and in section 2 you will see exactly what those 25 zeros do to the averages. Section 3 fixes it.

Relative and Absolute References

When you filled Revenue down, Excel moved every reference with it: F2*G2 in row 2 became F3*G3 in row 3. That is a relative reference, and it is what you want almost every time. But sometimes every row must use the same one cell, such as a rate. A $ in front of the column letter and row number locks it: $B$2 stays $B$2 in every row. That is an absolute reference.

Add a sheet called Settings and type the staff discount, 5%, in B2. We want each unit price with the staff discount taken off. First, without the $:

What this formula doesWe want each unit price less the staff discount in Settings!B2, written without $.
XTechPlug_Sales_Workbook.xlsx - Excel
After Enter and Fill Down
M2
fx
=G2*(1-Settings!B2)
D⋯G⋯M
1Product_NameUnit_PriceStaff_Price
2Thermocool AC 1.5HP380,000361,000
3Infinix Hot 4075,00075,000
4Anker Power Bank 20K28,00028,000
5Samsung 43" TV250,000250,000
Filled down from M2 to M1051: 1,050 rows. Rows 2, 3, 4, 5 shown.
Cleaning ProcessSales DataProduct CatalogueStaff DirectorySettings

Row 2 is right: 380,000 less 5% is 361,000. Every row after it is the full price. Click M3 and read the formula bar: it says Settings!B3, which is empty. Filling down moved the reference off the rate. Now with the $:

What this formula doesWe want the same calculation with the rate locked, so every row uses Settings!B2.
XTechPlug_Sales_Workbook.xlsx - Excel
After Enter and Fill Down
M2
fx
=G2*(1-Settings!$B$2)
D⋯G⋯M
1Product_NameUnit_PriceStaff_Price
2Thermocool AC 1.5HP380,000361,000
3Infinix Hot 4075,00071,250
4Anker Power Bank 20K28,00026,600
5Samsung 43" TV250,000237,500
Filled down from M2 to M1051: 1,050 rows. Rows 2, 3, 4, 5 shown.
Cleaning ProcessSales DataProduct CatalogueStaff DirectorySettings

Every row now has the discount. G2 still moves (G3, G4...) because each row needs its own price; $B$2 stays put because every row needs the same rate. A quick way to add the dollars: click the reference in the formula bar and press F4. Change M back to the Revenue formula before you go on.

Picture This

Picture a recipe card stuck to the fridge with a note: "salt: see the jar on the top shelf". The amounts change with the number of guests, but the salt always comes from the same jar. The guests are relative; the jar is absolute.

2. SUM, AVERAGE, COUNT, COUNTA, MIN and MAX

Definition

These six functions each take a range and return one number that describes it. They answer the first questions any manager asks: how much in total, how much on average, how many, the smallest and the biggest.

Real-Life Scenario

A class's test results. The teacher wants the total marks (SUM), the class average (AVERAGE), how many students wrote it (COUNT), how many names are on the list (COUNTA), and the lowest and highest score (MIN and MAX). Six questions, one column of numbers.

The Six Functions

FunctionAnswersCounts or uses
SUM(range)What is the total?Numbers only
AVERAGE(range)What is the typical value?Numbers only; empty cells and text are ignored, but a 0 counts
COUNT(range)How many numbers are there?Cells holding a number (or date)
COUNTA(range)How many cells are filled?Any cell that is not empty: text, numbers, anything
MIN(range)What is the smallest?Numbers only
MAX(range)What is the largest?Numbers only

We put the answers in a small summary block in columns O and P, away from the data. Each formula covers rows 2 to 1,051. Revenue in M is still =F2*G2 for now.

Function 1 and 2: SUM and AVERAGE

What these formulas doWe want the total revenue, and the average revenue per sale.
XTechPlug_Sales_Workbook.xlsx - Excel
After Enter
P2
fx
=SUM(M2:M1051)
OP
1QuestionAnswer
2Total revenue1,067,343,000
3Average sale1,016,517.14
Cleaning ProcessSales DataProduct CatalogueStaff Directory
What is typed in each cell
P2 =SUM(M2:M1051)
P3 =AVERAGE(M2:M1051)

TechPlug sold N1,067,343,000 from January to March 2024, and the average sale was N1,016,517.14. Hold on to that average.

Function 3 and 4: COUNT and COUNTA

What these formulas doWe want to count the sales two ways: how many Quantity cells hold a number, and how many Transaction_ID cells are filled.
XTechPlug_Sales_Workbook.xlsx - Excel
After Enter
P2
fx
=COUNT(F2:F1051)
OP
1QuestionAnswer
2Quantity cells with a number1025
3Sales (filled Transaction_ID cells)1050
4Revenue cells with a number1050
Cleaning ProcessSales DataProduct CatalogueStaff Directory
What is typed in each cell
P2 =COUNT(F2:F1051)
P3 =COUNTA(A2:A1051)
P4 =COUNT(M2:M1051)

COUNT on Quantity says 1,025; COUNTA on Transaction_ID says 1,050. The 25 missing are the blank quantities. But COUNT on Revenue says 1,050: every Revenue cell holds a number, because the blanks became 0. That is the problem. AVERAGE divided the total by 1,050 sales, including 25 sales that were counted as worth nothing. The average is too low.

COUNT or COUNTA?

COUNT on a text column, such as =COUNT(A2:A1051), returns 0, because Transaction_IDs are text. Use COUNTA to count records, and COUNT to count numbers. Comparing the two on a number column is a fast blank detector.

Function 5 and 6: MIN and MAX

What these formulas doWe want the smallest and the largest single sale.
XTechPlug_Sales_Workbook.xlsx - Excel
After Enter
P2
fx
=MIN(M2:M1051)
OP
1QuestionAnswer
2Smallest sale0
3Largest sale6,990,000
Cleaning ProcessSales DataProduct CatalogueStaff Directory
What is typed in each cell
P2 =MIN(M2:M1051)
P3 =MAX(M2:M1051)

The smallest "sale" is N0: not a real sale, one of the blanks. The largest is N6,990,000. MIN and MAX are quick validity checks, and here MIN has just caught the same problem COUNT did.

Try This

Add two rows to your summary block: the total number of units sold (SUM of Quantity) and the highest unit price (MAX of Unit_Price).

Check your answer

Units: =SUM(F2:F1051) gives 4,108. Highest price: =MAX(G2:G1051) gives 699,000 (the iPhone 14).

Picture This

Picture the teacher's mark sheet with six numbers at the bottom in red pen. If absent students were written in as 0, the average would look worse than the class really did. A blank and a zero are not the same thing.

3. IF and Nested IF

Definition

IF asks a yes-or-no question and gives one answer if it is true and another if it is false:

IF(test, value if true, value if false)

The test is a comparison, such as F2>5, or a function that answers TRUE or FALSE, such as ISBLANK(F2). The two values can be text in quotes, numbers, or other formulas.

Real-Life Scenario

A bouncer at a club door: "If you are on the list, come in; otherwise, go home." One question, two outcomes, the same rule for every person in the queue.

Example 1: Fixing Revenue

Revenue should be worked out only when Quantity is there, and left empty when it is not. In IF words: if F2 is blank, write nothing (two double quotes, ""), otherwise multiply.

What this formula doesWe want Revenue for every sale whose quantity is known, and an empty cell, not a 0, where it is not.
XTechPlug_Sales_Workbook.xlsx - Excel
After Enter and Fill Down
M2
fx
=IF(ISBLANK(F2),"",F2*G2)
A⋯FG⋯M
1Transaction_IDQuantityUnit_PriceRevenue
2TP-08923380,0001,140,000
3TP-0785475,000300,000
⋮⋮⋮⋮⋮
22TP-0511285,000
⋮⋮⋮⋮⋮
27TP-045410285,0002,850,000
⋮⋮⋮⋮⋮
32TP-05286699,0004,194,000
33TP-0379285,000
⋮⋮⋮⋮⋮
42TP-03589699,0006,291,000
⋮⋮⋮⋮⋮
46TP-006710450,0004,500,000
Filled down from M2 to M1051: 1,050 rows. Rows 2, 3, 22, 27, 32, 33, 42, 46 shown.
Cleaning ProcessSales DataProduct CatalogueStaff Directory
What these formulas doWe want the average sale again, now that the blanks are left out.
XTechPlug_Sales_Workbook.xlsx - Excel
After Enter
P2
fx
=AVERAGE(M2:M1051)
OP
1QuestionAnswer
2Average sale1,041,310.24
3Revenue cells with a number1025
4Total revenue1,067,343,000
Cleaning ProcessSales DataProduct CatalogueStaff Directory
What is typed in each cell
P2 =AVERAGE(M2:M1051)
P3 =COUNT(M2:M1051)
P4 =SUM(M2:M1051)

The total is the same, N1,067,343,000, because adding 0 never changed it. But AVERAGE now divides by the 1,025 sales whose value is known, and the average sale rises to N1,041,310.24. This is the Revenue column you keep. Every lesson from here uses it.

Example 2: High or Low, and the Trap

TechPlug wants every sale labelled High if its revenue is above N1,000,000 and Low otherwise.

What this formula doesWe want each sale labelled High when Revenue is above 1,000,000, and Low when it is not.
XTechPlug_Sales_Workbook.xlsx - Excel
After Enter and Fill Down
N2
fx
=IF(M2>1000000,"High","Low")
A⋯MN
1Transaction_IDRevenueSize
2TP-08921,140,000High
3TP-0785300,000Low
⋮⋮⋮⋮
22TP-0511High
⋮⋮⋮⋮
27TP-04542,850,000High
⋮⋮⋮⋮
32TP-05284,194,000High
33TP-0379High
⋮⋮⋮⋮
42TP-03586,291,000High
⋮⋮⋮⋮
46TP-00674,500,000High
Filled down from N2 to N1051: 1,050 rows. Rows 2, 3, 22, 27, 32, 33, 42, 46 shown.
Cleaning ProcessSales DataProduct CatalogueStaff Directory
The Part That Confuses Everyone

Rows 22 and 33 have no Revenue, yet IF called them High. Revenue there is empty text, "", and in a comparison Excel treats any text as bigger than any number. So all 25 sales with no quantity were labelled High, with no warning. (Had Revenue still been =F2*G2, they would have been 0 and labelled Low: wrong the other way.) An empty value is not big or small; it is unknown.

Example 3: Nested IF, Catching the Blanks First

An IF can sit inside another IF. The outer one checks for an empty Revenue first; only if there is a value does the inner one decide High or Low. M2="" asks "is M2 empty text?".

What this formula doesWe want Missing for sales with no Revenue, and High or Low for every other sale.
XTechPlug_Sales_Workbook.xlsx - Excel
After Enter and Fill Down
N2
fx
=IF(M2="","Missing",IF(M2>1000000,"High","Low"))
A⋯MN
1Transaction_IDRevenueSize
2TP-08921,140,000High
3TP-0785300,000Low
⋮⋮⋮⋮
22TP-0511Missing
⋮⋮⋮⋮
27TP-04542,850,000High
⋮⋮⋮⋮
32TP-05284,194,000High
33TP-0379Missing
⋮⋮⋮⋮
42TP-03586,291,000High
⋮⋮⋮⋮
46TP-00674,500,000High
Filled down from N2 to N1051: 1,050 rows. Rows 2, 3, 22, 27, 32, 33, 42, 46 shown.
Cleaning ProcessSales DataProduct CatalogueStaff Directory

Now 25 say Missing, 369 High and 656 Low. Read a nested IF from the left: the first test that is TRUE wins, and the rest are never looked at.

Example 4: Three Bands, and Why the Order Matters

Nested IF gives as many outcomes as you need. Large for N2,000,000 and above, Medium for N500,000 and above, Small for the rest. Check the biggest band first:

What this formula doesWe want every sale put in one of three size bands, testing the largest band first.
XTechPlug_Sales_Workbook.xlsx - Excel
After Enter and Fill Down
N2
fx
=IF(M2="","Missing",IF(M2>=2000000,"Large",IF(M2>=500000,"Medium","Small")))
A⋯MN
1Transaction_IDRevenueBand
2TP-08921,140,000Medium
3TP-0785300,000Small
⋮⋮⋮⋮
22TP-0511Missing
⋮⋮⋮⋮
27TP-04542,850,000Large
⋮⋮⋮⋮
32TP-05284,194,000Large
33TP-0379Missing
⋮⋮⋮⋮
42TP-03586,291,000Large
⋮⋮⋮⋮
46TP-00674,500,000Large
Filled down from N2 to N1051: 1,050 rows. Rows 2, 3, 22, 27, 32, 33, 42, 46 shown.
Cleaning ProcessSales DataProduct CatalogueStaff Directory
What this formula doesWe want to see what happens if the same bands are tested in the wrong order: Medium before Large.
XTechPlug_Sales_Workbook.xlsx - Excel
After Enter and Fill Down
N2
fx
=IF(M2="","Missing",IF(M2>=500000,"Medium",IF(M2>=2000000,"Large","Small")))
A⋯MN
1Transaction_IDRevenueBand
2TP-08921,140,000Medium
3TP-0785300,000Small
⋮⋮⋮⋮
22TP-0511Missing
⋮⋮⋮⋮
27TP-04542,850,000Medium
⋮⋮⋮⋮
32TP-05284,194,000Medium
33TP-0379Missing
⋮⋮⋮⋮
42TP-03586,291,000Medium
⋮⋮⋮⋮
46TP-00674,500,000Medium
Filled down from N2 to N1051: 1,050 rows. Rows 2, 3, 22, 27, 32, 33, 42, 46 shown.
Cleaning ProcessSales DataProduct CatalogueStaff Directory

In the right order there are 160 Large sales. In the wrong order there are none: a sale of N4,194,000 is above 500,000, so the Medium test says yes and Excel never reaches the Large test. Test from the most demanding condition to the least.

Picture This

Picture the bouncer with a second bouncer behind him: the first checks the list, and only people who pass reach the second, who checks the dress code. Whoever stands first decides who the second ever sees.

4. IFS

Definition

IFS takes pairs of test and result, in order, and returns the result of the first test that is TRUE. It does the same job as a nested IF without the pile of brackets:

IFS(test 1, result 1, test 2, result 2, ...)

IFS has no "otherwise". If no test is true it returns #N/A, so the last pair is usually TRUE, "result": TRUE is always true, so it catches everything left.

Real-Life Scenario

A school grading table on the wall: 70 and above is A, 60 and above is B, 50 and above is C, otherwise F. You read down it and stop at the first line that fits.

What this formula doesWe want the same size bands, written with IFS.
XTechPlug_Sales_Workbook.xlsx - Excel
After Enter and Fill Down
N2
fx
=IFS(M2="","Missing",M2>=2000000,"Large",M2>=500000,"Medium",TRUE,"Small")
A⋯MN
1Transaction_IDRevenueBand
2TP-08921,140,000Medium
3TP-0785300,000Small
⋮⋮⋮⋮
22TP-0511Missing
⋮⋮⋮⋮
27TP-04542,850,000Large
⋮⋮⋮⋮
32TP-05284,194,000Large
33TP-0379Missing
⋮⋮⋮⋮
42TP-03586,291,000Large
⋮⋮⋮⋮
46TP-00674,500,000Large
Filled down from N2 to N1051: 1,050 rows. Rows 2, 3, 22, 27, 32, 33, 42, 46 shown.
Cleaning ProcessSales DataProduct CatalogueStaff Directory

Exactly the same answer as the nested IF, row for row, and easier to read and change. Use IFS when you have Excel 2019 or newer; on older versions, nested IF does the same job.

Watch Out For This

Leave off the final TRUE,"Small" and every sale under N500,000 shows #N/A. And put the M2="" pair first, for the reason in section 3: empty text would otherwise pass the Large test.

5. AND and OR

Definition

AND returns TRUE only when every condition inside it is true. OR returns TRUE when at least one is. On their own they answer TRUE or FALSE; inside an IF, they let one test check two things.

Real-Life Scenario

A loan officer: "You get the loan if you earn over N500,000 AND have no unpaid loans" (both must be true). A bus conductor: "You ride free if you are a child OR a soldier in uniform" (either one is enough).

AND: Both Conditions

TechPlug's corporate team wants its bulk corporate sales: a Corporate customer buying 8 units or more.

What this formula doesWe want "Bulk corporate" on sales to Corporate customers of 8 units or more, and nothing on every other sale.
XTechPlug_Sales_Workbook.xlsx - Excel
After Enter and Fill Down
N2
fx
=IF(AND(K2="Corporate",F2>=8),"Bulk corporate","")
A⋯F⋯K⋯N
1Transaction_IDQuantityCustomer_TypeBulk_Corporate
2TP-08923Retail
3TP-07854Retail
⋮⋮⋮⋮⋮
22TP-0511Retail
⋮⋮⋮⋮⋮
27TP-045410Retail
⋮⋮⋮⋮⋮
32TP-05286Corporate
33TP-0379Corporate
⋮⋮⋮⋮⋮
42TP-03589Wholesale
⋮⋮⋮⋮⋮
46TP-006710CorporateBulk corporate
Filled down from N2 to N1051: 1,050 rows. Rows 2, 3, 22, 27, 32, 33, 42, 46 shown.
Cleaning ProcessSales DataProduct CatalogueStaff Directory

48 sales qualify. A Corporate sale of 6 units fails the second condition, and a Retail sale of 10 fails the first: AND needs both. The "" means "write nothing", which keeps the column easy to read.

OR: Either Condition

What this formula doesWe want "Lagos" on sales from either Lagos branch, and "Elsewhere" on every other sale.
XTechPlug_Sales_Workbook.xlsx - Excel
After Enter and Fill Down
N2
fx
=IF(OR(J2="Lagos Island",J2="Lagos Mainland"),"Lagos","Elsewhere")
A⋯J⋯N
1Transaction_IDBranchLagos
2TP-0892KanoElsewhere
3TP-0785AbujaElsewhere
⋮⋮⋮⋮
22TP-0511Port HarcourtElsewhere
⋮⋮⋮⋮
27TP-0454KanoElsewhere
⋮⋮⋮⋮
32TP-0528JosElsewhere
33TP-0379JosElsewhere
⋮⋮⋮⋮
42TP-0358Port HarcourtElsewhere
⋮⋮⋮⋮
46TP-0067Port HarcourtElsewhere
Filled down from N2 to N1051: 1,050 rows. Rows 2, 3, 22, 27, 32, 33, 42, 46 shown.
Cleaning ProcessSales DataProduct CatalogueStaff Directory

205 sales came from one of the two Lagos branches. This only works because Branch was cleaned in Week 2: " Lagos Island" with spaces would not equal "Lagos Island".

Overall Example: Every Idea From Today in One Column

What this formula doesWe want a Priority label for each sale: Missing when there is no quantity, Call today for bulk corporate sales or any sale over 3,000,000, Normal for the rest.
XTechPlug_Sales_Workbook.xlsx - Excel
After Enter and Fill Down
N2
fx
=IFS(M2="","Missing",OR(AND(K2="Corporate",F2>=8),M2>3000000),"Call today",TRUE,"Normal")
A⋯F⋯K⋯MN
1Transaction_IDQuantityCustomer_TypeRevenuePriority
2TP-08923Retail1,140,000Normal
3TP-07854Retail300,000Normal
⋮⋮⋮⋮⋮⋮
22TP-0511RetailMissing
⋮⋮⋮⋮⋮⋮
27TP-045410Retail2,850,000Normal
⋮⋮⋮⋮⋮⋮
32TP-05286Corporate4,194,000Call today
33TP-0379CorporateMissing
⋮⋮⋮⋮⋮⋮
42TP-03589Wholesale6,291,000Call today
⋮⋮⋮⋮⋮⋮
46TP-006710Corporate4,500,000Call today
Filled down from N2 to N1051: 1,050 rows. Rows 2, 3, 22, 27, 32, 33, 42, 46 shown.
Cleaning ProcessSales DataProduct CatalogueStaff Directory

Read it pair by pair: blanks first, then the AND inside the OR, then everything else. Result: 115 sales to follow up today, 25 missing, 910 normal. Every part of it was taught today. Delete column N when you finish: Week 3 Virtual 1 builds the columns you keep.

Practical Exercises

Exercise 1: Very Easy

Write =COUNTA(K2:K1051). Why is it 1,050, when Customer_Type had 15 blanks in Week 1?

Exercise 2: Simple Application

Label each sale Bulk if Quantity is 5 or more, and Single otherwise. What does it say on the blank quantities, and is that right?

Exercise 3: Combination

Label each sale "Paid later" if Payment_Method is Credit and Customer_Type is Wholesale, and leave every other row empty.

Exercise 4: A Small Real-World Problem

Write an IFS that gives each sale a payment group: Instant for POS or Transfer, Cash for Cash, Owed for Credit.

Answers to the exercises

Exercise 1: Step 5 of the Cleaning Process filled the 15 blanks with Unknown. Exercise 2: =IF(F2>=5,"Bulk","Single"); a blank counts as 0, so the 25 blanks say Single, which is not known. Catch them first with IF(ISBLANK(F2),"Missing",...). Exercise 3: =IF(AND(L2="Credit",K2="Wholesale"),"Paid later",""). Exercise 4: =IFS(OR(L2="POS",L2="Transfer"),"Instant",L2="Cash","Cash",L2="Credit","Owed").

Checkpoint

Q1. What does =10+10/2 return, and why?

15. Division happens before addition.

Q2. You fill =G2*(1-Settings!B2) down and only row 2 is right. What is wrong?

The rate reference moved as it was filled. Lock it: Settings!$B$2.

Q3. Why does =F2*G2 give the wrong average sale?

A blank Quantity counts as 0, so 25 unknown sales are averaged in as worth nothing.

Q4. Why did IF label the empty Revenue cells High?

They hold empty text, and Excel treats any text as bigger than any number in a comparison.

Q5. Why does testing Medium before Large give zero Large sales?

Every Large sale is also at least 500,000, so the first test catches it and IF stops there.

Q6. What does IFS return if no test is true and there is no TRUE at the end?

#N/A.

Tick Before You Move On

  • ☐ I can name the parts of a formula and predict the order Excel calculates in
  • ☐ Revenue is in column M as =IF(ISBLANK(F2),"",F2*G2), filled to row 1,051
  • ☐ I can lock a reference with $ (or F4), and I know when it is needed
  • ☐ I can use SUM, AVERAGE, COUNT, COUNTA, MIN and MAX on the right range
  • ☐ I know a blank becomes 0 in a calculation, and empty text beats any number in a comparison
  • ☐ I can write IF, catch blanks with a nested IF, and order bands correctly
  • ☐ I can write the same logic with IFS, and combine conditions with AND and OR

Quick Recap

A formula starts with =, follows BODMAS, and updates when its inputs change. Revenue is Quantity times Unit_Price, left empty where Quantity is unknown. Relative references move when filled; $ locks a reference that every row must share. SUM, AVERAGE, COUNT, COUNTA, MIN and MAX describe a whole column in one number each. IF chooses between two answers; nested IF and IFS between many, first true test wins. Catch empty values first: a blank is 0 in a sum, and empty text is "bigger" than any number.

Final Scenario

TechPlug's finance team reports an average sale of N1,016,517. The sales team says their average is higher.

You put COUNT on Quantity next to COUNTA on Transaction_ID: 1,025 against 1,050. Finance used =F2*G2, so 25 sales with unknown quantities went into the average as worth nothing. With Revenue left empty on those rows, the average is N1,041,310.

Both teams were right about what they could see. The difference was one IF.

The two counts disagreeing was the whole answer.

Next, Week 3, Virtual 1: you add Size and Zone columns on your own and make the numbers readable at a glance with conditional formatting.

Learn this with a real instructor

Free lessons take you a long way on your own. The full programmes add live classes, assignments, Skill Points and a certificate — built for African students.