Reputation: 47
I have some data where I want to find the minimum number of days it takes to reach a total sum based on some criteria.
Essentially the data is like this:
Date Season Recieval
1/01/2006 2006 500
2/01/2006 2006 100
3/01/2006 2006 150
…
10/12/2009 2009 300
etc
Want I want to do is find a formula that finds the minimum number of days it takes to reach a receivals total for the season.
The formula below is what I have tried so far with no avail.
=MIN(COUNT(IF(SUMIFS(C:C,B:B,"2006")>2000,DATA!A:A)))
It doesn't matter what point it starts from, but it must take the minimum number of days to reach the 2000.
Output should be a number eg 39 (39 days consecutive to sum up to receivals of 2000).
Essentially what I want to generate is the minimum number of consecutive days required to reach the total of 2000, regardless of the starting point.
Cheers!
Upvotes: 0
Views: 173
Reputation: 9976
If your Dates are in the range A2:A25 and Recieval in C2:C25, then try this...
=INDEX(A2:A25,MATCH(TRUE,INDEX(SUBTOTAL(9,(OFFSET(C$2:C25,,,ROW(INDIRECT("1:25")),1)))>=2000,),0))-A2
The formula will get you the no. of days to reach total 2000 receival in column C.
Or if you just need to count the consecutive dates, please try..
=MATCH(TRUE,INDEX(SUBTOTAL(9,(OFFSET(C$2:C25,,,ROW(INDIRECT("1:25")),1)))>=2000,),0)
Remember both the formulas are Array Formulas which require a special key stroke Ctrl+Shift+Enter instead of Enter alone.
Upvotes: 1