Countif with last 5 values

Viewed 76
1 Answers

since the dates are in descending order all you need is:

=QUERY(FILTER({K2:K, Z2:Z}, 
 COUNTIFS(K2:K, K2:K, ROW(K2:K), "<="&ROW(K2:K))<6), 
 "select Col1,sum(Col2) where Col1 !='' group by Col1 label sum(Col2)''")

enter image description here

Related