Knowledge base / Excel

AVERAGEIFS: multiple criteria and dates with times

Five requests illustrate simultaneous conditions, aligned columns, and a month selection that includes times on its final day.

Kajo RudzińskiPublished Updated 4 min read

Two gates select components meeting both criteria before averaging

When I need an average for a particular queue, status, and month, the conditions must apply together. AVERAGEIFS selects those observations before averaging. I first check that all columns describe the same rows. The correct function name cannot rescue a calculation that pairs one request’s status with another request’s time.

Syntax: the average range comes first

Microsoft documents this argument order:

=AVERAGEIFS(average_range, criteria_range1, criteria1, ...)

Start with the numbers, then supply range-and-criterion pairs. Every condition must hold for the corresponding row: this is AND logic. AVERAGEIF uses a different order, so do not transfer the arguments mechanically.

These examples use English names and commas. The Polish function is ŚREDNIA.WARUNKÓW. Match the argument separator to your settings, as explained in Microsoft’s separator guide.

A shared table for two criteria

The data is synthetic. Put headers in A1:D1 and five requests in A2:D6. Column D contains numeric minutes. Column C must contain actual Excel dates with times, rather than text that merely resembles a timestamp.

Row A: Queue B: Status C: Completion or observation D: Time
2 A Done 2026-01-01 00:00 10
3 A Done 2026-01-31 18:00 30
4 A Open 2026-01-15 12:00 50
5 B Done 2026-01-20 09:00 20
6 A Done 2026-02-01 00:00 80

The question is the mean for queue A and status Done:

=AVERAGEIFS(D2:D6, A2:A6, "A", B2:B6, "Done")

Rows 2, 3, and 6 qualify. Row 4 fails the status condition; row 5 fails the queue condition. The remaining times are 10, 30, and 80 minutes. Their sum is 120 across three observations, giving 40 minutes. Walking through the rows makes it clear why satisfying just one criterion is insufficient.

January with times: include the start, exclude the next month

You can create unambiguous date values with these formulas in C2:C6. DATE combines a year, month, and day, while TIME represents a time of day.

Cell Formula
C2 =DATE(2026,1,1)
C3 =DATE(2026,1,31)+TIME(18,0,0)
C4 =DATE(2026,1,15)+TIME(12,0,0)
C5 =DATE(2026,1,20)+TIME(9,0,0)
C6 =DATE(2026,2,1)

I add a January interval to the previous question:

=AVERAGEIFS(D2:D6, A2:A6, "A", B2:B6, "Done", C2:C6, ">="&DATE(2026,1,1), C2:C6, "<"&DATE(2026,2,1))

Row 2 lies exactly at the start and stays. Row 3 stays too, despite containing 18:00 on the month’s last day. Row 6 equals the next month’s boundary and is excluded. The result is (10+30)/2, or 20 minutes.

I derive this selection from the two numeric comparisons and Microsoft’s description of date and time values. A condition of <=DATE(2026,1,31) would stop at midnight at the beginning of 31 January. It would not include the whole day with times. The condition <DATE(2026,2,1) covers January without guessing the last possible second.

A conveyor with a lit interval between its start and the next period’s boundary

Dimensions, alignment, and meaning

Unlike AVERAGEIF, AVERAGEIFS requires matching range sizes and shapes. I also check starting rows. A2:A6 and D3:D7 have equal lengths but pair different requests. Matching dimensions and matching observations are separate requirements for a meaningful calculation.

I use explicit categories A and B and consistent status names. If a source has similar labels, establish their meanings before reporting. Do not assume the text’s appearance is a sufficient classification rule. The example should represent agreed categories rather than depend on incidental spelling in a particular import.

If no row meets all conditions, the function returns #DIV/0!. That is different from a zero mean. I first inspect selected records and check the date type, status, and ranges. Only after establishing the cause do I choose how to present the missing result. Catching every error can also hide a problem you did not intend to ignore.

Two common mistakes in the question

Adding conditions for queue A and queue B on the same column does not mean “A or B”. No row in this table belongs to both queues, so none can meet both conditions. Design a combined-group selection separately when needed. Adding another criterion pair will not change the function’s method of combining conditions.

I also avoid averaging two group means without inspecting the measurement counts. In the original table, the question concerns individual requests. Replacing them with group summaries changes the unit of observation. Establish whether the report should represent a typical request or a typical group. This is a decision about the metric’s meaning, worth agreeing before writing the formula.

A boundary exercise

Change C6 to 31 January 2026 at 23:00 while keeping the other data. Row 6 now qualifies for January, and the mean for A and Done returns to 40 minutes. Restore 1 February at 00:00: the result is 20 again. Explain the difference through the interval boundaries rather than the date’s appearance in the cell.

Key takeaways

Must every criterion be met?

Yes. The function combines conditions with AND. Conditions A and B on one category do not create an A-or-B selection.

How do I include a whole month with times?

Use the month start as an inclusive boundary and the next month start as an exclusive boundary.

Are equal range lengths sufficient?

No. Sizes and shapes must match, and corresponding cells should represent the same observations.

AI was used in an automated way while working on this article. If you want to learn how to do it too, check out this project.

Kajo Rudziński

Newsletter KajoData

Let’s keep in touch.

I write about data analysis, learning and changing careers. My newsletter and the sign-up form are in Polish. If that works for you, I’d be glad to see you there.