Reputation: 455
I have difficulties with the following scenario.
I need to get the amount (count) of the product ordered in a specific time range (today + 8 days back).
The problem is that the results in column [D] are wrong according to my need. In row 7 you can see that this product was ordered twice in the last 8 days, but this is wrong.
Second example (colored orange) is correct, but only because both dates are within the range of past 8 days.
My current formula in column [D] is:
=IF(A2>=TODAY()-8,COUNTIF(B$2:B$10,B2),"")
I think it's not possible to use COUNTIFS (multiple criteria) in combination with the date restriction, right? What is the correct approach for this use case?
Upvotes: 1
Views: 683
Reputation: 152450
Yes you can use a formula in the criteria, The range part has to be a range not an array.
COUNTIFS(B$2:B$10,B2,$A$2:$A$10,">="&TODAY()-8)
So:
=IF(A2>=TODAY()-8,COUNTIFS(B$2:B$10,B2,$A$2:$A$10,">="&TODAY()-8),"")
Upvotes: 3