views:

58

answers:

1

I have data that looks like the following:

ID      | Location | Attendees | StartDate | EndDate
---------------------------------------------
Event1  | Bldg 1   | 10        | June 1    | June 5
Event2  | Bldg 2   | 15        | June 3    | June 6
Event3  | Bldg 1   | 5         | June 3    | June 10

I'd like to create a time series graph showing, for every given date, how many events were active on that date (i.e. started but haven't ended yet). For example, on June 1, there was 1 active event, and on June 4, there were 4 active events.

This should be simple enough to do by creating a new range where my first column consists of consecutive dates, and the second column consists of formulas like the following (I hardcoded June 8 in this example):

=COUNTIFS(Events[StartDate],"<=6/8/2009", Events[EndDate],">6/8/2009")

However, the challenge is that I'd like to be able to dynamically filter the time series graph based on various criteria. For example, I'd like to be able to quickly switch between seeing the above time series only for events in Bldg 1; or for Events with more than 10 attendees. I have at least 10 different criteria I'd like to be able to filter on.

What is the best way to do this? Does Excel have a built-in way to do this, or should I write the filtering code in VBA?

+3  A: 

Apart from that my answer is not programming related: That's prime example for using a pivot table. Use this to show data consolidated for e.g. each day. Then you can play around with filtering as you like.

Your question is exactly what pivot tables are made for.

Marco
Thanks Marco -- I tried this, but couldn't see how to do it: I entered StartDate in "Row Labels" and then put "Count of ID" in "Values", but that just gave me how many events were started opened on that date. The number I need to figure out is [Count of events started to date] - [Count of events finished to date]. Is that possible in a pivot table?
RexE
Okay. Now I see that I misinterpret your requirements. I think your approach with =COUNTIFS() was not bad. But =COUNTIFS() ignore filters. This is your problem, right?Using formulas considering filters, can be done with =SUBTOTAL(). In combination with =SUMPRODUCT(), you can use filtering like in =COUNTIFS(). Maybe it is worth to give it a try.
Marco
Just google for "countif subtotal" as many other users have already tried to simulate =COUNTIF() inside =SUBTOTAL().
Marco
Thanks Marco! You understood my issue correctly. I'll try out your recommendation.
RexE