BUS 120 · Spreadsheets and Business Data
Formulas and Essential Functions
Build formulas that follow the order of operations and use SUM, AVERAGE, COUNT, ROUND and conditional totals.
Key takeaways
- Formulas follow an order of operations, and parentheses are how you take control of it.
- A function is a named, ready-made calculation that takes inputs called arguments inside parentheses.
- AVERAGE and COUNT ignore empty cells and text, so a blank and a zero can give different results.
- ROUND changes the stored number, while formatting only changes what you see.
- SUMIFS, COUNTIFS and AVERAGEIFS total or count only the rows that meet your conditions.
Two roommates, Dev and Lena, sell homemade candles at a weekend market. Dev types =10+5*2 to price a gift set and expects 30. The sheet says 20. Dev insists the computer is broken. Lena, who paid attention in algebra, quietly takes the laptop.
The computer was not broken. It follows a strict set of rules about which step comes first. It also comes with hundreds of ready-made calculations, so you rarely need to build one from scratch. You only need a good handful, and you need to know their habits.
Operators and who goes first
A formula starts with an equals sign. Inside it you use operators, the symbols that do arithmetic.
| Symbol | Meaning | Example | Result |
|---|---|---|---|
| + | add | =8+2 | 10 |
| - | subtract | =8-2 | 6 |
| * | multiply | =8*2 | 16 |
| / | divide | =8/2 | 4 |
| ^ | raise to a power | =8^2 | 64 |
| & | join text | ="Job "&7 | Job 7 |
The order of operations is the rule for which step happens first. Parentheses come first. Then powers. Then multiplication and division, left to right. Then addition and subtraction, left to right.
So =10+5*2 gives 20, because 5 × 2 happens first. To add first, write =(10+5)*2, which gives 30. When in doubt, add parentheses. They are free.
One Excel quirk deserves a warning. A minus sign in front of a single number is applied before a power. So =-3^2 returns 9. Written as =-(3^2), it returns -9.
Excel applies a leading minus sign even before powers, so use parentheses to be clear.
Functions: ready-made calculations
A function is a named calculation built into the program. You write its name, then its inputs in parentheses. The inputs are called arguments, and commas separate them. Some regional settings use semicolons instead.
In =ROUND(B2,2), the function is ROUND. The first argument is the number in B2. The second says to keep two decimal places.
As you type a function name, a small hint shows which argument comes next. Read it. It is the cheapest manual ever printed.
The five you will use every day
- SUM adds numbers: =SUM(D2:D7).
- AVERAGE adds them and divides by how many there are.
- MIN returns the smallest value.
- MAX returns the largest value.
- COUNT counts the cells that hold numbers.
Two relatives are worth knowing. COUNTA counts every cell that is not empty, including text. COUNTBLANK counts the empty ones.
Here is the candle stall's market log. Dev and Lena sold on six days, but on day 4 they forgot to write down sales, so the cell is empty.
| Row | A (Day) | B (Product line) | C (Units) | D (Sales $) |
|---|---|---|---|---|
| 2 | 1 | Soy | 12 | 180 |
| 3 | 2 | Beeswax | 5 | 110 |
| 4 | 3 | Soy | 20 | 300 |
| 5 | 4 | Beeswax | ||
| 6 | 5 | Soy | 8 | 120 |
| 7 | 6 | Beeswax | 10 | 220 |
=SUM(D2:D7) → 180 + 110 + 300 + 120 + 220 = 930
=COUNT(D2:D7) → 5
=AVERAGE(D2:D7) → 930 ÷ 5 = 186
=MAX(D2:D7) → 300
=MIN(D2:D7) → 110
=COUNTA(B2:B7) → 6 Notice the average. It divides by 5, not 6, because the empty cell is ignored. If Dev types 0 into D5, the average becomes 930 ÷ 6 = 155, and MIN becomes 0.
Which is right? It depends on what happened. If they sold nothing, enter 0. If they simply lost the record, leave it blank and add a note. A blank means "unknown." A zero means "none." Accountants should never mix those up.
Weighted totals with SUMPRODUCT
Sometimes you need to multiply pairs and then add the results. Suppose Dev sells 12 small candles at $8 and 5 large ones at $20. The units are in B2 and B3, and the prices are in C2 and C3.
SUMPRODUCT does both steps at once: =SUMPRODUCT(B2:B3, C2:C3) returns 12 × 8 + 5 × 20 = 196. Divide that by the total units and you get the average price per candle sold: 196 ÷ 17 is about $11.53.
That is not the same as averaging the two prices, which would give $14. The simple average ignores the fact that far more small candles were sold. When quantities differ, weight by them.
Rounding: what you see is not always what you have
Suppose a candle costs $2.675 in wax and wick, and the cell is formatted to show two decimals. The screen shows a rounded figure, but the cell still holds 2.675. Multiply by 1,000 candles and you get $2,675, which is not what the shown price would suggest.
ROUND actually changes the number. Its form is =ROUND(number, digits).
| Formula | Result |
|---|---|
| =ROUND(14.3862, 2) | 14.39 |
| =ROUND(14.3862, 0) | 14 |
| =ROUND(14386, -2) | 14400 |
| =ROUNDUP(14.321, 1) | 14.4 |
| =ROUNDDOWN(14.389, 1) | 14.3 |
A negative number of digits rounds to the left of the decimal point. ROUNDUP always moves away from zero. ROUNDDOWN always moves toward zero.
When should you round? Round when the real world rounds, such as an invoice line charged to the cent. Otherwise, keep full precision in your calculations and round only for display. Rounding early lets tiny differences pile up.
Percent of total and percent change
Two small formulas show up in almost every business sheet, so learn them early.
A percent of total tells you how big one part is compared with the whole. Divide the part by the total. If soy candles brought in 600 of the 930 in sales, the formula =600/930 returns about 0.645, or 64.5%. In a real sheet you would point at cells and lock the total, as in =D2/$D$9, so that you can copy the formula down.
A percent change tells you how much something grew or shrank. Subtract the old figure from the new one, then divide by the old one. Suppose the stall sold 800 last month and 930 this month. The formula is =(930-800)/800, which gives 130 ÷ 800 = 0.1625, or 16.25% growth.
The parentheses matter. Without them, =930-800/800 divides first and returns 929. That answer is so odd that you would probably notice. With other numbers, you might not.
Also watch the starting point. If last month's figure is zero or blank, the formula returns #DIV/0!. There is no sensible percent change from nothing, so say that in words instead.
If you format a cell as a percentage, do not multiply by 100 yourself. The format already does that on screen. Doing both turns 16.25% into 1625%.
Totals with conditions
Dev asks, "How much did we make from soy candles?" You could add rows by hand. Or you could let a conditional function do it, one that includes only rows passing a test.
=SUMIFS(D2:D7, B2:B7, "Soy") → 180 + 300 + 120 = 600
=COUNTIFS(B2:B7, "Soy") → 3
=AVERAGEIFS(D2:D7, B2:B7, "Soy") → 600 ÷ 3 = 200 SUMIFS takes the range to add first. Then come pairs: a range to test and the condition it must meet. Add more pairs to narrow things down. To total soy sales on days with at least 10 units:
=SUMIFS(D2:D7, B2:B7, "Soy", C2:C7, ">=10") → 180 + 300 = 480 Day 5 drops out because it sold only 8 units. Conditions with comparison signs go inside quotation marks. To use a number stored in a cell, join it on: ">="&F1.
You may also see the older SUMIF and COUNTIF, which handle one condition. SUMIF lists its arguments in a different order, with the sum range last. Many people use SUMIFS every time to avoid the mix-up.
A worked example: price, cost and profit
Lena builds a profit calculator. She types inputs in their own cells, following the habit from cells and references. All figures are invented.
| Cell | Label | Value |
|---|---|---|
| B1 | Price per candle | 15 |
| B2 | Materials per candle | 6 |
| B3 | Candles sold | 80 |
| B4 | Booth fee | 150 |
| B5 | Card fee rate | 3% |
Then she writes the calculations.
B7 Revenue: =B1*B3 → 15 × 80 = 1,200
B8 Materials: =B2*B3 → 6 × 80 = 480
B9 Card fees: =ROUND(B7*B5,2) → 1,200 × 0.03 = 36.00
B10 Profit: =B7-B8-B9-B4 → 1,200 - 480 - 36 - 150 = 534
B11 Margin: =B10/B7 → 534 ÷ 1,200 = 0.445 Format B11 as a percentage and it shows 44.5%. This assumes every sale is paid by card, which keeps the example simple.
Example with made-up numbers.
Now check the work a second way. Each candle sells for 15 and uses 6 of materials. The card fee is 3% of 15, which is 0.45. So each candle leaves 15 - 6 - 0.45 = 8.55. Eighty candles leave 80 × 8.55 = 684. Subtract the 150 booth fee and you get 534. The two methods agree.
This habit of checking by another route is worth more than any single function. If two honest paths give different answers, one formula is wrong, and you have found it before anyone else did.
Because the inputs sit in their own cells, Lena can test ideas quickly. If she changes B3 from 80 to 100, revenue becomes 1,500, materials 600 and card fees 45. Profit becomes 1,500 - 600 - 45 - 150 = 705.
Want to know how many candles cover all costs? That question belongs to break-even analysis, and your input cells make it easy to explore.
The common mistake: the total that skips a row
Lena later types =D2+D3+D4+D6+D7 to total sales. She skipped D5 because it was empty. The answer is correct today: 930.
Next week Dev finds the missing record and types 150 into D5. The total still says 930. It should say 1,080.
=SUM(D2:D7) would have caught the new figure. Use a range whenever you are adding a block. Also avoid writing =SUM(D2+D3+D4). It works by accident, since the plus signs do the adding before SUM sees anything.
A second trap is inserting a new row just below the last row of a range. The total may or may not stretch to include it, depending on the program and settings. After adding rows, click the total and check which cells it covers.
Reading errors without panic
Spreadsheets report trouble with short codes.
| Code | Usual meaning |
|---|---|
| #DIV/0! | You divided by zero or by an empty cell |
| #VALUE! | A value is the wrong type, such as text in arithmetic |
| #NAME? | A function or name is misspelled |
| #REF! | A formula points to a cell that no longer exists |
| ##### | The column is often just too narrow |
When you see a code, do not hide it right away. Click the cell, read the formula and follow it back to its inputs. The code is a clue about where the trouble started. One bad cell can spread its error to every formula that depends on it, so fix the earliest one first.
You can type functions inside other functions, which is called nesting. For example, =ROUND(AVERAGE(D2:D7),0) averages first, then rounds. Read nested formulas from the inside out.
If a nested formula grows past what you can explain aloud, split it into two or three cells with labels. Extra cells cost nothing. A formula nobody understands can cost a great deal.
Next up, logical and text functions let your sheet make decisions and tidy up messy words.
Words to know
Operator a symbol such as + or * that performs a step in a formula.
Order of operations the rule that decides which part of a formula is calculated first.
Function a named calculation built into the spreadsheet.
Argument one input that you give to a function inside its parentheses.
Conditional function a function that counts or totals only the rows that pass a test.
Nesting placing one function inside another.
Precision how many digits of a number the cell actually keeps and uses.
Check yourself
- What does =20-4*3 return, and why?
- Cells A1 to A4 hold 10, 20, an empty cell and 30. What do AVERAGE and COUNT return?
- What does =ROUND(5287.4, -2) return?
- Using the market log, what is =SUMIFS(D2:D7, B2:B7, "Beeswax")?
- If B1 is 20, B2 is 8 and B3 is 50, what does =(B1-B2)*B3 return?
- Why is =SUM(D2:D7) safer than typing each cell with plus signs?
Show the answers
- It returns 8, because 4 × 3 = 12 is calculated before 20 - 12.
- AVERAGE returns 60 ÷ 3 = 20 and COUNT returns 3, since the empty cell is ignored.
- It returns 5300, because -2 rounds to the nearest hundred.
- Beeswax rows hold 110, an empty cell and 220, so the total is 330.
- It returns (20 - 8) × 50 = 600.
- A range covers every cell in the block, so a value filled in later is included without editing the formula.