Question

I have two columns, one for the date and one for the number of people who cannot make it to an event on that date. The date is formatted as an excel date. I would like to find the first date to which the least number of people cannot make it AFTER the current date. Ideally I'd like to solve the problem without resorting to VBA macros.

Was it helpful?

Solution

Given column A=Dates, B=Number of people Add a third collumn with:

=IF(A1>TODAY(),B1,"")

Then use a Lookup to find the date of the smallest entry:

=INDEX(A:A,MATCH(MIN(C:C),C:C,0))

Updated with Barrys fix (thanks!)

OTHER TIPS

Assume dates are in A2:A100 and numbers in B2:B100 try this "array formula"

=MIN(IF(A2:A100>TODAY(),IF(B2:B100=MIN(IF(A2:A100>TODAY(),B2:B100)),A2:A100))

formula needs to be confirmed with CTRL+SHIFT+ENTER so that curly braces like { and } appear around the formula in the formula bar

That finds the smallest date (the earliest) which is both after today and has the lowest number for the dates after today

OK this is a fun one to figure out :)

Unfortunately this approach doesn't take in to account the current date, you can solve for that by sorting the data by ascending date and then limit the MAX and MATCH functions to the date range you are searching inside (I'm not enough of an Excel master to figure out a way to do this without some form of pre-organized data).

Lets use the following Data:

     A       | B
1  1/05/2012 | 1
2  2/14/2012 | 4
3  3/17/2012 | 2
4  4/01/2012 | 3
5  5/12/2012 | 1

Using the values in column B as attendees, and A as dates you can see the earliest/highest with this (implementing Berry's suggestion (making the function more readable)):

=INDEX(A1:A5, MATCH(MAX(B1:B5),B1:B5,0), 1)

In case someone else can figure out what I am missing, here is a break down of what is happening:

=MAX(B1:B5) -> 4
Looks for the largest attendees count

=MATCH(MAX(B1:B5),B1:B5,0) -> 2
find the first row where this number occurs.

=INDEX(A1:A5, MATCH(MAX(B1:B5),B1:B5,0), 1) -> 2/14/2012
which is the value found at that row in the first column
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top