AVERAGEIFS criteria: 5 checks for dog costs
BiscuitHare Editorial Team ·
AVERAGEIFS averages dog costs that meet your conditions; check criteria pairs, criteria forms, empty cells, TRUE and FALSE values, and amounts.
Key takeaways
- Choose the dog and category you want to compare.
- Review unfinished entries before using the average in a budget.
- Keep a short note beside each important formula explaining what it covers.
If you keep a spreadsheet of what your dog costs, you probably have one long list. Each row is a single expense: a date, your dog's name, a category such as grooming, vet, food, or boarding, and an amount. Adding the amounts with SUM is easy. Averages are more useful and harder to get right. You might want to know what a typical grooming visit costs, what the average vet bill was over the past year, or what a bag of food costs on average across the time you have kept records.
AVERAGEIFS is the function built for that job. The Microsoft AVERAGEIFS page is the reference for the rules in this post. The function is simple to start with, but it has limits that can quietly give you a wrong number. Some are about how many conditions you can add. Others are about how blank cells, TRUE and FALSE values, and text are read. This post walks through five limits to check before you trust the answer on your sheet.
You do not need to know any programming for this. If you can type a formula into a cell and fill it down a column, you can follow along. The examples use standard spreadsheet syntax. If your numbers look off in another app, check that app's own help for the same function.
Set up the sheet before you write a formula
Before you write any formula, make the sheet easy to average. Use one row for each expense. Do not squeeze several amounts into one cell, and do not start a new column each month. Put each kind of information in its own column, and keep the header row short and consistent. A simple layout works well:
- Column A: Date
- Column B: Dog
- Column C: Category
- Column D: Amount
- Column E: Paid (TRUE or FALSE)
For the wider setup, follow the dog cost sheet steps. Every range in a formula should cover the same rows.
The function takes the average range first, and then pairs of criteria ranges and criteria. For the average of one dog's grooming costs, use this formula:
=AVERAGEIFS(D:D, B:B, "Biscuit", C:C, "Grooming")
Here D:D is the average range. B:B with "Biscuit" is the first pair, and C:C with "Grooming" is the second. A row is averaged only when every condition is true. Keep that rule in mind, because it explains most of the surprises later in this post.
Use these headings to keep the expense records consistent:
| Row | Dog | Category | Amount | Paid |
|---|---|---|---|---|
| Example | Dog name | Care category | Illustrative amount | Paid value |
Use "Needs check" for a category you still need to review. Keep that habit in mind for limit 3. A groomer visit sheet can help you keep the visit details alongside your costs.
Limit 1: You can use up to 127 pairs
The Microsoft page says the function accepts "1 to 127 ranges in which to evaluate the associated criteria." It also accepts "1 to 127 criteria in the form of a number, expression, cell reference, or text that define which cells will be averaged."
A dog cost sheet will almost never come near that number. The more realistic problem is a formula with four or five conditions that is so hard to read that you cannot tell whether it is right. When a formula gets that long, a helper column usually helps more than adding another pair.
For example, put a combined label in column F. Enter this in F2 and fill it down:
=B2&" - "&C2
Each row now shows a label such as "Biscuit - Grooming." Use that label as a single criterion:
=AVERAGEIFS(D:D, F:F, "Biscuit - Grooming")
The label also makes the sheet easier to audit. You can scan column F, filter it, and see exactly which rows the formula will pick up. If the label looks wrong, the average will be wrong too, so the helper column is worth the extra step.
If you track more than one dog, the same idea scales across the whole sheet. A label that joins the dog's name and the category, such as "Dog name - Category," lets you compare dogs without writing a separate condition for each one. Use the same label pattern in every row, though. A label that uses a hyphen with no spaces in some rows and a spaced dash in others will split one group into two, and each formula will see only part of the data.
Limit 2: Criteria can be numbers, text, cell references, or expressions
The Microsoft page gives a short list of the forms a criterion can take: "For example, criteria can be expressed as 32, "32", ">32", "apples", or B4." Each form does a different job on a cost sheet.
- Text such as "Grooming" goes in quotation marks inside the formula.
- A cell reference such as $H$1 lets you change the dog or category without editing the formula. Type the name you want in H1, and point the formula at that cell.
- An expression such as ">32" limits rows by a comparison. Microsoft's own example is "Average second quiz grade that is greater than 95 for all students." The same pattern works for costs. You could average only the grooming visits that cost more than a threshold you store in a cell.
To average grooming costs above the threshold in H3 for the dog named in H1, use:
=AVERAGEIFS(D:D, B:B, $H$1, C:C, "Grooming", D:D, ">"&$H$3)
This formula uses the amount column twice. It is the range being averaged, and it is also the range the comparison runs against. That mirrors the quiz example Microsoft uses. Storing the threshold in a cell means you can change it without touching the formula.
Most errors with criteria come from small differences in the text. A stray space at the end of a cell, a plural in one row and a singular in another, or a typo in the dog's name will change which rows match. The sheet will not complain. It will simply leave rows out. Before you rely on a formula, filter the sheet by the same text and compare the count of rows to what the formula used.
Cell references are also the easiest way to build a small summary. List each dog in column H, put the same formula in column I, and fill both down.
=AVERAGEIFS($D:$D, $B:$B, H2, $C:$C, "Grooming")
Now one column shows each dog's average grooming cost, and you can check the whole summary at a glance. If one dog's cell shows the error discussed later in this post, you know exactly which name to look at.
Limit 3: Empty cells in a criteria range count as 0
The Microsoft page states: "If a cell in a criteria range is empty, AVERAGEIFS treats it as a 0 value." This limit catches many people, because blank cells are normal on a cost sheet. You might enter a visit's date and amount right away but leave the category empty until you check the bill.
Because the function reads that blank as 0, it does not match "Grooming." If a grooming visit sits on a row with an empty category, its amount is left out of the Biscuit grooming average, so the average is calculated from fewer rows and may not reflect all of your grooming visits. Nothing in the result tells you a row was skipped, so the problem is easy to miss.
Three habits prevent this:
- Fill in every category before you average. If you do not know the category yet, enter "Other" or "Needs check." A temporary label is better than a blank, because it shows up in your results and you can find it with a filter.
- Check the formula against rows you know. Pick three or four rows, add their amounts by hand, divide by the count, and compare that result to the formula's answer.
- Be careful with criteria that could match 0. Review empty cells when checking these comparisons, especially in a long sheet.
Limit 4: TRUE counts as 1 and FALSE counts as 0
The Microsoft page says: "Cells in range that contain TRUE evaluate as 1; cells in range that contain FALSE evaluate as 0 (zero)." A Paid column is common on expense sheets.
Some guidance for a Paid column:
- Keep the column pure. Use only TRUE or FALSE in every row. A mix of TRUE, "yes," and "x" makes the results hard to check, and a half-filled column hides the rows you most need to see.
- Decide what the column means before you average. If you want the average cost of visits that were paid, write down which value means paid. Then confirm the formula uses that value.
- Test with known rows. Mark each expense TRUE or FALSE. Add up the amounts of one dog's paid grooming visits by hand, divide by how many there are, and compare the formula to that result.
Be careful about reading more into a Paid column than it holds. An average of paid visits is only the average of the rows that are marked paid. It says nothing about the unpaid bills, which may be the costs you most need to see.
Limit 5: The average range should hold numbers
The Microsoft page describes the average range as "One or more cells to average, including numbers or names, arrays, or references that contain numbers." For your sheet, that means the Amount column should contain real numbers in every row you average.
A cell can look like a number and still not be one. An amount pasted from a bank export with a currency symbol, a leading apostrophe, or a stray space may be stored as text. Text may not be averaged the way you expect, so the result can be quietly wrong. The fix is to check before you average, not after.
Here are two checks you can do in a few minutes:
- Test each amount. In a spare column, enter =ISNUMBER(D2) and fill it down the sheet. Check the result against amounts you know are numbers. Inspect any cell that differs.
- Clean the column. Remove currency symbols and stray spaces, then set the column's format to a number or currency format. Retype any cell that still needs attention after that.
To review the amounts, put =COUNT(D:D) in a spare cell and compare it with =COUNTA(D:D). Compare the counts with a manual check of your entries. Keep the header separate from expense rows when checking your entries. If the counts differ, inspect the amounts rather than assuming which cells caused the difference.
Keep totals out of the data rows, too. If you add a "Total" line at the bottom of the amount column, it becomes part of the range that your averages use. Put totals in a separate area, away from the columns your formulas read.
Illustrative example: Check a grooming average
Illustrative grooming costs of 40 and 40 have an average of 40. A vet cost of 800 is excluded by the "Grooming" criterion. Check that your grooming formula returns 40 before adding further conditions. If it does not, inspect the category labels and the amount cells.
Today, choose a dog and category, check the matching rows by hand, and compare your result with the formula before using it in your budget.
What #DIV/0! means
Why does AVERAGEIFS return #DIV/0!?
AVERAGEIFS returns #DIV/0! when no cells meet all the criteria. The Microsoft page states: "If there are no cells that meet all the criteria, AVERAGEIFS returns the #DIV/0! error value."
On a cost sheet, the usual causes are these:
- A spelling difference. The formula says "Grooming," but the sheet says "Groming" or "Grooming " with a trailing space.
- A condition that excludes everything. A comparison such as "greater than the value in H3" returns #DIV/0! if no grooming visit is above that threshold.
- Rows outside the ranges. You used fixed ranges, added rows below them, and the formula does not reach the new rows.
How can you find the condition causing the error?
To find the cause, remove conditions one at a time. Start with the full formula, then delete the last pair and check the result. When a number appears, the condition you just removed is the one that blocked every row. Then look at how that condition is written in the formula and in the sheet.
Should you replace the error with a message?
Check the criteria before replacing the error with a message. Some people wrap the formula in IFERROR so the sheet shows a friendly message, such as "No visits yet," instead of the error. That can be reasonable once you have confirmed the criteria. Before you add it, check for a wrong range or a typo. A wrong range or a typo can then look like an empty result with no warning.
Keep the number honest
An average is only as good as the rows behind it. A few grooming visits will give you an average that jumps around with each new expense, while a longer record will settle into something steadier. Before you use the number to plan a budget, look at how many rows it is based on. A formula that returns an answer from a handful of rows is not the same as one built from a long record.
It also helps to write a short note beside each important formula. Say which dog it covers, which categories and date range it uses, and when you last checked it against a few known rows. When you open the sheet months later, the note will tell you whether the number still means what you think it means.
If your hand calculation and formula disagree, go back through the five limits in order and check each against the matching expense rows.