Sub topic 2
Totaling Many Rows or Fetching One Value
This chapter assumes you know basic Excel formulas, relative and absolute references, and the layout of a simple budget or financial statement. You will work with a flat data table and an assumptions table.
Two different jobs
Financial models usually need one of two operations:
- Aggregation combines many source rows into one total. Use this for questions such as “What are total travel expenses?” or “What was revenue in March?”
- Lookup retrieves one value associated with a key. Use this for questions such as “What is the tax rate?” or “What is the budget for Marketing?”
The distinction matters because the formulas answer different questions.
| Task | Source pattern | Typical function |
|---|---|---|
| Total matching transactions | Many rows match the criteria | `SUMIFS` |
| Retrieve one assumption | One key should match one value | `XLOOKUP` |
Aggregating many rows with SUMIFS
Assume the Data sheet contains these columns:
- Column B: account
- Column C: category
- Column D: transaction date
- Column F: amount
A report row has an account name in A5. To total every matching amount, use:
=SUMIFS(Data!$F$2:$F$5000, Data!$B$2:$B$5000, $A5)SUMIFS starts with the sum range. It then receives pairs of criteria ranges and criteria. In this formula, Excel adds values from column F when the account in column B equals the value in A5.
You can add more conditions. For example, this formula totals one account and one category:
=SUMIFS(Data!$F$2:$F$5000, Data!$B$2:$B$5000, $A5, Data!$C$2:$C$5000, "Opex")The ranges must cover the same rows. If the sum range has 4,999 rows but a criteria range has 4,998, the formula can produce incorrect results or an error.
Retrieving one value with XLOOKUP
Assume Assumptions contains keys in column B and values in column C. If A5 contains the key to find, use:
=XLOOKUP($A5, Assumptions!$B$3:$B$12, Assumptions!$C$3:$C$12, "Missing assumption")The arguments are:
- The lookup value:
$A5 - The lookup array: the key range
- The return array: the value range
- The not-found result:
"Missing assumption"
Unlike SUMIFS, XLOOKUP is intended to return a single matching value. If duplicate keys exist, it normally returns the first match. That behavior can hide a data-quality problem, so key columns should be designed to contain one row per key.
Worked decision
For a monthly expense report, use SUMIFS because many ledger transactions may belong to the same account. For a tax-rate assumption, use XLOOKUP because the model expects one rate for one named assumption.
Exercise
Which function should total all transactions for the account in A5, and which should retrieve the tax rate for the key in A5?
Show answer
Use SUMIFS for the transactions because many rows may match. Use XLOOKUP for the tax rate because one key should return one assumption.