Your formula is saying this:
=AVERAGEIFS(E1:E4,A1:A4,"=today()-1",B1:B4,">16:00",C1:C4,"=today()",D1:D4,"<16:00")
Take the average of E1:E4 if...
- A1:A4 are equivalent to the string "=today()-1"
- B1:B4 are equivalent to the string ">16:00"
- C1:C4 are equivalent to the string "=today()"
- D1:D4 are equivalent to the string ">16:00"
What you want it to say is:
Take the average of E1:E4 if...
- A1:A4 are equivalent to the result of the formula
=today()-1
- B1:B4 are less than 16 hours
- C1:C4 are equivalent to the result of the formula
=today()
- D1:D4 are less than 16 hours
Let's tackle 2 and 4 first.
In Excel, 1 day (24 hours) = 1. Times are stored as decimal values as a percentage of a day:
1 day = 1 1 day = 24 hours 1 hour = 1 / 24 16 hours = 16/24 = 2/3
So instead of B1:B4,">16:00"
you should rewrite the formula as:
B1:B4,">"&2/3
The &
concatenates the greater than sign, and 2/3 will give the decimal value equivalent to 16:00. In the end you will get a string equal to ">.6666666666"
(You can also just use B1:B4,">.6666666666666"
if you'd like)
For items 1 and 3, you don't need to use quotes at all. So instead of A1:A4,"=today()-1"
you can just use the following:
A1:A4,today()-1
C1:C4,today()
Putting this all together, the following formula should work:
=AVERAGEIFS(E1:E4,A1:A4,today()-1,B1:B4,">"&2/3,C1:C4,today(),D1:D4,"<"&2/3)