View Single Post
 
Old 06-25-2013, 07:14 PM
BobBridges's Avatar
BobBridges BobBridges is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: May 2013
Location: USA
Posts: 700
BobBridges has a spectacular aura aboutBobBridges has a spectacular aura about
Default

Hm, well, I don't know what the function helper was thinking but the fact that it did that may mean there's an easier way to do this that I don't know about. (You'll remember that I've never used COUNTIFS before.) But now I see what you mean about capturing times in a certain slot, say midnight to 0100.

Let's start over. You have a full timestamp in col C. Col B displays the day of the week, and col D the time of day. You want to count up how many rows there are where col F is "Outage" and the outage occurs a) on a specified day of the week and b) within a specified hour of the day.

I now know how to go about it—I just tested it in my own spreadsheet—but first let me suggest one minor change that I think will make it simpler: Change the formula in column D from =TEXT(Cn,"hh:mm") to =Cn-INT(Cn). That strips off the days from the timestamp, leaving just the fractional part, which indicates the time of day.

Next: Rather than hard-code the day in the formulae you're using a value specified in A$311. I suggest you do the same for the time slot: You can put in 0 for midnight-to-0100, 1 for 0100-0200 and so on. Personally I would have put those in a more accessible set of cells such as G2 and G3, but since you're already using A311 I'll pretend we're going to put the hour argument in there too. So in A312 you put a number between 0 and 23. Then in A313 and A314 you put the starting and ending times that will go in the COUNTIFS formula, as follows:

A313: =">="&TIME($A312,0,0)
A314: ="<"&TIME(A$312+1,0,0)

The COUNTIFS call, then would look like this:

=COUNTIFS(HFC!$B:$B,$A$311,HFC!F:F,"Outage",HFC!D: D,A$313,HFC!D,A$314)

Couldn't you just put ">="&TIME(A312,0,0) and "<"&TIME(A312+1,0,0) directly in the formula? Sure. It might be better, too; I just liked the look of breaking up the long formula into smaller parts.

This seems to work on my PC.
Reply With Quote