📝 Module 19: Other Important General Formulas
Beyond the core calculation functions covered in previous modules, Excel contains a rich library of functions for working with text, performing conditional sums and counts with multiple criteria, looking up data intelligently, and performing mathematical operations. This module covers the most important and frequently used formulas from these categories — SUMIF, SUMIFS, COUNTIF, COUNTIFS (in depth), text functions (LEFT, MID, RIGHT, LEN, TRIM, UPPER, LOWER, PROPER, CONCATENATE, TEXTJOIN), the mathematical essentials (ROUND, INT, MOD, ABS), and SUMPRODUCT for advanced weighted calculations. Every formula here is drawn from real South African office scenarios.
19.1 SUMIF and SUMIFS — Conditional Summing
SUMIF sums values in a range that meet a single condition. SUMIFS sums values meeting multiple conditions simultaneously. These are the workhorses of financial reporting and data analysis.
SUMIF Syntax
=SUMIF(range, criteria, [sum_range])
- range: where to look for the condition (the column to check)
- criteria: what to match — text, number, comparison, wildcard, or cell reference
- [sum_range]: optional — the column to sum. If omitted, sums the range itself.
SUMIF Examples
| Task | Formula |
| Total sales for Gauteng only | =SUMIF(B2:B100,"Gauteng",C2:C100) |
| Sum invoices over R50,000 | =SUMIF(C2:C200,">50000") |
| Sum all amounts except "Cancelled" | =SUMIF(D2:D100,"<>Cancelled",C2:C100) |
| Sum for a region in cell F1 | =SUMIF(B2:B100,F1,C2:C100) |
| Sum all "Pty" company names (wildcard) | =SUMIF(A2:A100,"*Pty*",C2:C100) |
| Sum non-blank amounts | =SUMIF(C2:C100,"<>""",C2:C100) |
SUMIFS Syntax
=SUMIFS(sum_range, criteria_range1, criteria1, [criteria_range2, criteria2], …)
Note: In SUMIFS, the sum_range comes first, then each criteria pair. In SUMIF, the range comes first and sum_range is last. This reversal is a common mistake when switching between the two.
SUMIFS Examples
| Task | Formula |
| Gauteng sales for Q1 (Jan–Mar) | =SUMIFS(C2:C200,B2:B200,"Gauteng",A2:A200,">="&DATE(2025,1,1),A2:A200,"<="&DATE(2025,3,31)) |
| Finance dept salary > R40,000 | =SUMIFS(D2:D100,C2:C100,"Finance",D2:D100,">40000") |
| Revenue from Active clients in Durban | =SUMIFS(E2:E200,B2:B200,"Durban",F2:F200,"Active") |
| Overdue invoices (date before today) | =SUMIFS(C2:C100,D2:D100,"<"&TODAY(),E2:E100,"Unpaid") |
Criteria Formats for SUMIF / SUMIFS
| Criteria Type | How to Write It | Example |
| Exact text match | In quotes | "Gauteng" |
| Exact number match | No quotes | 50000 |
| Comparison | Operator + value in quotes | ">50000" "<=0" "<>Cancelled" |
| Cell reference as criteria | Operator in quotes & cell reference | ">"&F1 (where F1 contains 50000) |
| Wildcard (contains) | * for any characters | "*Cape*" matches Cape Town, Cape Winelands |
| Wildcard (starts with) | text* or ? for single char | "Johan*" matches Johannesburg |
| Date comparison | Operator & DATE() function | ">="&DATE(2025,1,1) |
19.2 Text Functions
Text functions extract, transform, and combine text values in cells. They are essential for cleaning imported data, reformatting names and codes, building dynamic labels, and preparing data for reports.
LEFT, RIGHT, MID — Extracting Parts of Text
| Function | Syntax | Example (A2 = "Johannesburg") |
| LEFT |
=LEFT(text, num_chars) |
=LEFT(A2,6) → "Johann" |
| RIGHT |
=RIGHT(text, num_chars) |
=RIGHT(A2,4) → "burg" |
| MID |
=MID(text, start_num, num_chars) |
=MID(A2,3,5) → "hanne" (start at char 3, take 5) |
LEN — Length of Text
=LEN(text)
=LEN("Johannesburg") → 12
=LEN(A2) → number of characters in A2 (including spaces and punctuation)
Common uses:
=IF(LEN(A2)=13,"Valid ID","Wrong length") — SA ID validation
=IF(LEN(A2)>50,"Too long","OK") — field length check
=LEN(TRIM(A2)) — length after removing extra spaces
TRIM — Remove Extra Spaces
=TRIM(text)
TRIM removes all leading spaces, trailing spaces, and reduces multiple spaces between words to a single space.
=TRIM(" Cape Town ") → "Cape Town"
=TRIM("Cape Town") → "Cape Town" (double space becomes single)
When to use: after importing data from other systems (CSV, web, PDF) that often adds extra whitespace.
UPPER, LOWER, PROPER — Converting Case
| Function | What It Does | Example (A2 = "john smith") |
| UPPER | Converts all text to UPPERCASE | =UPPER(A2) → "JOHN SMITH" |
| LOWER | Converts all text to lowercase | =LOWER(A2) → "john smith" |
| PROPER | Capitalises the First Letter of Each Word | =PROPER(A2) → "John Smith" |
SA Names Note: PROPER capitalises every word including "van", "de", "du" and South African prefixes like "Nkosi", "Dlamini" which usually look correct. However it would capitalise "VAN DER MERWE" to "Van Der Merwe" — review surnames that should stay lowercase based on cultural convention.
FIND and SEARCH — Locating Text Within Text
| Function | Syntax | Key Difference |
| FIND |
=FIND(find_text, within_text, [start_num]) |
Case-sensitive: "A" and "a" are different |
| SEARCH |
=SEARCH(find_text, within_text, [start_num]) |
Not case-sensitive: "A" and "a" are the same. Also supports wildcards (* and ?). |
Both return the position number of the first character of the found text, or a #VALUE! error if not found. Use with IFERROR to handle the not-found case:
=FIND("@",A2) → position of @ in email address
=LEFT(A2, FIND("@",A2)-1) → extract username before the @
=IFERROR(SEARCH("Cape",A2),"Not found") → check if "Cape" appears anywhere
=IF(ISNUMBER(SEARCH("Pty",A2)),"Company","Individual") → company type check
SUBSTITUTE — Replace Text
=SUBSTITUTE(text, old_text, new_text, [instance_num])
=SUBSTITUTE(A2,"(Pty) Ltd","") — remove "(Pty) Ltd" from company names
=SUBSTITUTE(A2," ","_") — replace spaces with underscores (for file names)
=SUBSTITUTE(A2,"-","") — remove hyphens from phone numbers
=SUBSTITUTE(A2,"R","",1) — remove the first R (Rand symbol) from currency text
CONCATENATE (&) and TEXTJOIN — Joining Text
Joining text from multiple cells is done with the & operator or the TEXTJOIN/CONCAT functions:
Joining with &:
=A2&" "&B2 → "John Smith" (first + space + last)
=A2&", "&B2 → "Smith, John" (last, first)
="ID: "&A2&" | "&B2 → "ID: 8001015009087 | John Smith"
TEXTJOIN (Excel 2019+ — joins a range with a delimiter, optionally skipping blanks):
=TEXTJOIN(", ",TRUE,A2:A10) → "Cape Town, Durban, Pretoria" (skips blanks)
=TEXTJOIN(" - ",FALSE,A2:C2) → joins 3 columns with " - " separator
CONCAT (joins a range without a delimiter):
=CONCAT(A2:D2) → joins all cells without any separator
VALUE and TEXT — Converting Between Numbers and Text
=VALUE(text) → converts text that looks like a number to a real numeric value
=VALUE("1500") → 1500 (the number, not text)
=VALUE(MID(A2,3,2)) → converts extracted ID digits to a number for comparison
=TEXT(value, format_code) → converts a number to formatted text
=TEXT(A2,"dd/mm/yyyy") → "15/01/2025" (date as text string)
=TEXT(B2,"R #,##0.00") → "R 1,500.00" (number as formatted currency text)
="Total: "&TEXT(SUM(C2:C10),"R #,##0") → "Total: R 12,500"
19.3 Essential Mathematical Functions
ROUND, ROUNDUP, ROUNDDOWN
| Function | Syntax | Example (value: 15.4678) |
| ROUND |
=ROUND(number, num_digits) |
=ROUND(A2,2) → 15.47 (rounds to 2 decimal places, standard rounding) |
| ROUNDUP |
=ROUNDUP(number, num_digits) |
=ROUNDUP(A2,2) → 15.47 (always rounds away from zero) |
| ROUNDDOWN |
=ROUNDDOWN(number, num_digits) |
=ROUNDDOWN(A2,2) → 15.46 (always rounds toward zero, truncates) |
num_digits values:
2 → round to 2 decimal places (R15.47)
0 → round to nearest whole number (15)
-1 → round to nearest 10 (20)
-2 → round to nearest 100 (0 for 15.47)
SA payroll uses: =ROUND(Salary*VATRate,2) — round VAT to 2 decimal places
=ROUNDUP(Hours*Rate,2) — always round up to the nearest cent when calculating pay
INT and TRUNC — Whole Number Functions
| Function | What It Does | Example |
| INT |
Returns the integer part, always rounding down toward negative infinity |
=INT(9.9) → 9 =INT(-9.1) → -10 |
| TRUNC |
Removes the decimal part, always truncating toward zero (keeps the integer) |
=TRUNC(9.9) → 9 =TRUNC(-9.1) → -9 |
Practical uses of INT:
=INT((B2-A2)*24) → complete hours worked (drops fractional hour)
=INT(A2/12) → complete years from months
=INT(TODAY()-A2)/365 → approximate age in years (less precise than DATEDIF)
MOD — Remainder After Division
=MOD(number, divisor) → returns the remainder after dividing number by divisor
=MOD(10,3) → 1 (10 ÷ 3 = 3 remainder 1)
=MOD(15,2) → 1 (odd number; even numbers give 0)
=MOD(16,2) → 0 (even number)
Practical uses:
Odd/Even row shading: =IF(MOD(ROW(),2)=0,"Even row","Odd row")
Overnight shift duration: =MOD(EndTime-StartTime,1)*24 — handles times crossing midnight
Instalment schedule: =IF(MOD(ROW()-1,12)=0,"Annual renewal","Regular month")
Check if divisible: =IF(MOD(A2,7)=0,"Weekly milestone","Not a milestone")
ABS — Absolute Value
=ABS(number) → returns the positive (absolute) value regardless of sign
=ABS(-250) → 250
=ABS(B2-A2) → difference between two numbers, always positive
=ABS((B2-A2)/A2) → variance magnitude without caring about direction
Practical uses:
=ABS(Actual-Budget) → total deviation amount (ignores whether over or under)
=SUM(ABS(B2:B10)) → only as an array formula (Ctrl+Shift+Enter in older Excel)
CEILING and FLOOR — Rounding to Multiples
=CEILING(number, significance) → rounds UP to the nearest multiple of significance
=CEILING(14,5) → 15 (nearest multiple of 5 at or above 14)
=CEILING(0.0671,0.01) → 0.07 (round UP to 2 decimal places)
=FLOOR(number, significance) → rounds DOWN to the nearest multiple
=FLOOR(17,5) → 15 (nearest multiple of 5 at or below 17)
=FLOOR(B2*60,15) → round meeting duration down to nearest 15 minutes
SA uses:
=CEILING(Salary/160,0.5) → hourly rate rounded up to nearest 50 cents
=FLOOR(Hours,0.25) → round hours down to nearest quarter-hour for billing
POWER and SQRT
=POWER(number, power) → equivalent to number^power
=POWER(2,10) → 1024 (same as =2^10)
=POWER(1+GrowthRate,Years) → compound growth factor
=SQRT(number) → square root
=SQRT(144) → 12
=SQRT(B2) → square root of the value in B2
19.4 SUMPRODUCT — The Multi-Purpose Power Function
SUMPRODUCT multiplies corresponding elements of two or more arrays and then sums the results. It is one of Excel's most versatile functions — used for weighted averages, conditional sums without helper columns, cross-tabulation, and counting with complex criteria without Ctrl+Shift+Enter.
Syntax
=SUMPRODUCT(array1, [array2], [array3], …)
Basic SUMPRODUCT — Weighted Total
Invoice total without a helper column:
Quantity in B2:B10, Unit price in C2:C10
=SUMPRODUCT(B2:B10, C2:C10)
→ Multiplies each quantity by its price, then sums all products
→ Equivalent to: =B2*C2 + B3*C3 + B4*C4 + … + B10*C10
Weighted average student score:
Scores in B2:B5, Weights in C2:C5 (e.g., 40%, 30%, 20%, 10%)
=SUMPRODUCT(B2:B5, C2:C5) → weighted average (if weights sum to 1)
=SUMPRODUCT(B2:B5, C2:C5)/SUM(C2:C5) → weighted avg when weights don't sum to 1
SUMPRODUCT as a Conditional Sum (No SUMIFS Needed)
=SUMPRODUCT((criteria_range=criteria)*sum_range)
Gauteng sales:
=SUMPRODUCT((B2:B100="Gauteng")*C2:C100)
→ (B2:B100="Gauteng") creates an array of 1s (TRUE) and 0s (FALSE)
→ Multiplying by C2:C100 keeps only Gauteng values; others become 0
→ SUM of results = total Gauteng sales
Multiple conditions (Gauteng AND > R50,000):
=SUMPRODUCT((B2:B100="Gauteng")*(C2:C100>50000)*C2:C100)
SUMPRODUCT for Counting
Count Gauteng entries (equivalent to COUNTIF):
=SUMPRODUCT((B2:B100="Gauteng")*1)
or: =SUMPRODUCT(--(B2:B100="Gauteng")) — the -- converts TRUE/FALSE to 1/0
Count with two conditions (Gauteng AND Finance):
=SUMPRODUCT((B2:B100="Gauteng")*(C2:C100="Finance"))
Count unique values in a range (distinct count):
=SUMPRODUCT(1/COUNTIF(A2:A100,A2:A100))
→ each value contributes 1/n where n = how many times it appears; sum = distinct count
SUMPRODUCT vs SUMIFS
| Aspect | SUMIFS | SUMPRODUCT |
| Performance | Faster on large datasets | Slower on very large datasets (whole-array calculation) |
| Flexibility | Limited to equality/comparison criteria | Handles calculated conditions and array operations |
| Array entry | Standard Enter key | Standard Enter key (no Ctrl+Shift+Enter needed) |
| Best for | Standard multi-criteria sums (most cases) | Weighted calculations, distinct counts, complex array logic |
19.5 LARGE, SMALL and RANK — Ranking Functions
LARGE and SMALL
=LARGE(array, k) → the k-th largest value
=LARGE(B2:B100, 1) → same as MAX (1st largest)
=LARGE(B2:B100, 2) → 2nd largest value
=LARGE(B2:B100, 3) → 3rd largest value
=SMALL(array, k) → the k-th smallest value
=SMALL(B2:B100, 1) → same as MIN (1st smallest)
=SMALL(B2:B100, 2) → 2nd smallest value
Top 3 average: =AVERAGE(LARGE(B2:B100,{1,2,3})) — array constant {1,2,3}
RANK
=RANK(number, ref, [order])
number → the value to rank
ref → the range of values to rank against (use absolute reference)
order → 0 or omitted = rank from largest (1 = highest); 1 = rank from smallest (1 = lowest)
=RANK(B2,$B$2:$B$51,0) → rank of B2 among all values B2:B51, highest = rank 1
=RANK(B2,$B$2:$B$51,1) → rank of B2, lowest = rank 1 (for error rates, absences)
In a leaderboard: copy =RANK(B2,$B$2:$B$51,0) down to B51 to rank all employees.
Note: Tied values receive the same rank (e.g., two employees tied for 3rd both get rank 3;
the next is ranked 5, not 4). Use RANK.EQ for the same behaviour or RANK.AVG for average rank.
19.6 Practical SA Formula Combinations
Cleaning Imported Employee Data
Raw name in A2 (may have extra spaces, wrong case):
Cleaned name: =PROPER(TRIM(A2))
Email from name: =LOWER(SUBSTITUTE(TRIM(A2)," ",".")&"@company.co.za")
→ "john.smith@company.co.za"
Split first/last name (assumes one space between):
First name: =LEFT(A2,FIND(" ",A2)-1)
Last name: =MID(A2,FIND(" ",A2)+1,LEN(A2))
Invoice and Financial Report Formulas
Amount due label: ="Amount due: "&TEXT(B2,"R #,##0.00")
→ "Amount due: R 12,500.00"
VAT line: =ROUND(B2*0.15,2) → VAT rounded to nearest cent
Total incl VAT: =ROUND(B2*1.15,2)
Overdue amount (sum of all unpaid invoices older than 30 days):
=SUMIFS(C2:C100,D2:D100,"Unpaid",A2:A100,"<"&(TODAY()-30))
Regional performance (% of national total):
=SUMIF(B2:B100,E2,C2:C100)/SUM(C2:C100) → formatted as %
Payroll Calculations
Employee reference code: =UPPER(LEFT(B2,3))&TEXT(ROW()-1,"000")
→ "SMI001", "NKO002" etc.
Department payroll total:
=SUMIF(DeptColumn,DeptName,SalaryColumn)
Count staff earning above average:
=SUMPRODUCT((Salaries>AVERAGE(Salaries))*1)
Payslip reference: ="PS"&TEXT(TODAY(),"yyyymm")&TEXT(A2,"000")
→ "PS202501001" (payslip for Jan 2025, employee 001)
19.7 Quick Self-Check
Q1: Your sales data has Region in column B and Revenue in column C. You need: (a) total revenue for Gauteng, (b) total revenue for Gauteng where individual revenue exceeds R50,000. Write both formulas.
✓ (a) =SUMIF(B2:B100,"Gauteng",C2:C100) — sums all C values where B equals "Gauteng". (b) =SUMIFS(C2:C100,B2:B100,"Gauteng",C2:C100,">50000") — sums C values where B = "Gauteng" AND C > 50,000. Note the SUMIFS argument order: sum_range first, then each criteria pair. The criteria ">50000" must be in quotes because it contains a comparison operator.
Q2: A cell A2 contains " John Smith " (with leading and trailing spaces and a double space in the middle). Write a formula that returns "John Smith" with proper capitalisation and all extra spaces removed, and a second formula that creates the email address john.smith@skailit.co.za from the same cell.
✓ Cleaned name: =PROPER(TRIM(A2)). TRIM removes all extra spaces first, then PROPER capitalises each word's first letter. Result: "John Smith". Email address: =LOWER(SUBSTITUTE(TRIM(A2)," ",".")&"@skailit.co.za"). TRIM removes spaces, SUBSTITUTE replaces the remaining single space with a period, LOWER converts to lowercase, and & joins the email domain. Result: "john.smith@skailit.co.za".
Q3: You have invoice values in column B (B2:B100) and need the total value including 15% VAT, rounded to the nearest cent. Write the formula.
✓ =ROUND(SUM(B2:B100)*1.15,2). SUM adds all invoice values, *1.15 adds 15% VAT to the total, and ROUND with 2 decimal places rounds to the nearest cent. It is important to use ROUND here rather than just formatting — ROUND changes the actual stored value, which matters for financial accuracy. Alternative if VAT is applied per invoice then summed: =SUMPRODUCT(ROUND(B2:B100*1.15,2)) ensures rounding happens per invoice rather than on the total, which can differ by a few cents in accounting contexts.
Q4: You have a list of 50 salesperson names in A2:A51 and their sales totals in B2:B51. Write a formula to rank the salesperson in B2 from highest to lowest (1 = top performer), and write a formula to find the 2nd highest sales figure in the list.
✓ Rank formula: =RANK(B2,$B$2:$B$51,0). The $B$2:$B$51 must be absolute (locked) so the reference range does not shift as the formula is copied down the column. The 0 as the third argument ranks from largest to smallest (1 = highest sales). Copy this formula from B2 down to B51 for all salesperson ranks. 2nd highest: =LARGE($B$2:$B$51,2). LARGE returns the k-th largest value; k=2 gives the 2nd largest. The absolute reference ensures the range stays fixed.
Q5: What does =SUMPRODUCT((B2:B100="Gauteng")*C2:C100) calculate, and how does it differ from =SUMIF(B2:B100,"Gauteng",C2:C100)?
✓ Both formulas calculate the exact same result: the sum of all values in C2:C100 where the corresponding cell in B2:B100 equals "Gauteng". SUMPRODUCT works by: (1) creating an array of TRUE/FALSE values from (B2:B100="Gauteng") — TRUE where the region is Gauteng; (2) multiplying each TRUE/FALSE by the corresponding C value (TRUE=1, FALSE=0), so non-Gauteng rows become 0; (3) summing the resulting array. The functional difference: SUMPRODUCT is more flexible — you can embed calculated conditions and array operations that SUMIF cannot handle. SUMIF is faster and simpler for straightforward criteria. Use SUMIF for single-condition sums; use SUMPRODUCT when you need complex array logic, weighted calculations, or distinct counts that SUMIF/SUMIFS cannot express.
Q6: A column of data should have values between 1 and 100, but some entries are outside that range. Write a SUMPRODUCT formula to count how many cells in B2:B100 are either less than 1 or greater than 100 (i.e., invalid).
✓ =SUMPRODUCT(((B2:B100<1)+(B2:B100>100)>0)*1). This creates two arrays: one for values below 1 and one for values above 100. Adding them together with + gives >0 wherever either condition is true (handles the OR logic). The >0 converts any positive number back to TRUE/FALSE, and *1 converts TRUE/FALSE to 1/0. SUMPRODUCT then sums the 1s to give the total count of invalid entries. Alternative using a simpler approach: =SUMPRODUCT(--(B2:B100<1))+SUMPRODUCT(--(B2:B100>100)) — two separate SUMPRODUCT formulas added together, counting below-1 entries plus above-100 entries separately.
✓ Module 19 Complete — You Have Learned:
- SUMIF — syntax (range, criteria, sum_range); 6 examples including wildcards and not-equal; note that sum_range is optional (sums range itself if omitted)
- SUMIFS — syntax (sum_range first, then criteria pairs); 4 multi-condition examples including date ranges; note sum_range comes first (opposite of SUMIF)
- Criteria formats — 7 formats (exact text, exact number, comparison in quotes, cell reference with operator &, wildcards *, starts-with, date with DATE())
- Text functions: LEFT/RIGHT/MID (extract); LEN (length, used in ID validation); TRIM (remove extra spaces from imports); UPPER/LOWER/PROPER (case conversion, SA names note); FIND (case-sensitive position) vs SEARCH (case-insensitive + wildcards); SUBSTITUTE (replace text); & operator and TEXTJOIN (join ranges with delimiter, skip blanks); VALUE (text to number) and TEXT (number to formatted string)
- ROUND/ROUNDUP/ROUNDDOWN — syntax; num_digits (positive = decimals, 0 = whole, negative = tens/hundreds); CEILING/FLOOR (round to multiples); SA payroll rounding use cases
- INT (round down to integer, goes negative for negative numbers) vs TRUNC (truncate toward zero); MOD (remainder, odd/even detection, overnight time, milestone check); ABS (absolute value, variance magnitude); POWER and SQRT
- SUMPRODUCT — multiplies arrays element-by-element then sums; weighted total without helper column; conditional sum with (condition)*range; counting with --(condition); distinct count with 1/COUNTIF; SUMPRODUCT vs SUMIFS comparison table
- LARGE/SMALL (k-th largest/smallest; top 3 average with array constant {1,2,3}); RANK (highest=1 with order 0; lowest=1 with order 1; tied values get same rank; RANK.EQ and RANK.AVG variants)
- Practical SA combinations — cleaning imported names (PROPER+TRIM); email generation (LOWER+SUBSTITUTE+&); split first/last name (LEFT/MID+FIND); invoice labels with TEXT; overdue sum with SUMIFS and TODAY(); employee reference codes; payslip references; payroll distinct staff count above average
← Back to All Modules