Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Number of records between two dates that lasted longer than 1 minute

I need to count the number of events/records in a simple table with dates of appointments and how long the appointments lasted, in another table I have two cells to take dated (start and end dates) these give a range. I want to count the number of appointments that lasted longer than one minute that fall within the test range.


I'm sure it's COUNTIFS and I have tried to get it to work.


Hope you can help.


Thanks

iMac, OS X Mavericks (10.9.2), Numbers 3.2

Posted on Feb 7, 2016 7:00 AM

Reply
Question marked as Best reply

Posted on Feb 7, 2016 1:40 PM

You could do something like this

User uploaded file

The data is the table on the left and is named "Data"


The table on the right summarizes the data. Enter the Start Date, End Date, and Min Duration.

D2=COUNTIFS(Data::B, ">="&C2, Data::A, ">="&A2, Data::A, "<="&B2)


this is shorthand for... select cell D2, then type (or copt and paste from here) the formula:

=COUNTIFS(Data::B, ">="&C2, Data::A, ">="&A2, Data::A, "<="&B2)

4 replies
Question marked as Best reply

Feb 7, 2016 1:40 PM in response to P33DEE

You could do something like this

User uploaded file

The data is the table on the left and is named "Data"


The table on the right summarizes the data. Enter the Start Date, End Date, and Min Duration.

D2=COUNTIFS(Data::B, ">="&C2, Data::A, ">="&A2, Data::A, "<="&B2)


this is shorthand for... select cell D2, then type (or copt and paste from here) the formula:

=COUNTIFS(Data::B, ">="&C2, Data::A, ">="&A2, Data::A, "<="&B2)

Feb 7, 2016 1:46 PM in response to Wayne Contello

Hi Wayne - thank you for your help (just need a bit more if that's ok) everything you said worked perfectly - I just can't work out how to replace the &C2 with the constant 0 Minutes - I could "fiddle" it by creating a "dummy" cell to contain the value but from a maintenance point of view I think it would be cleaner to use a constant. Hope this makes sense and hope you can help.

Feb 7, 2016 10:00 PM in response to P33DEE

Hello


You may try something like this.



User uploaded file



REPORT (excerpt) A1 [ stat A2 2016-01-04 A3 2016-01-11 B1 end ] B2 2016-01-10 B3 2016-01-17 C1 count > 1 min C2 =COUNTIFS(LOG::B,">1",LOG::A,">="&A2,LOG::A,"<"&(B2+1)) C3 =COUNTIFS(LOG::B,">1",LOG::A,">="&A3,LOG::A,"<"&(B3+1))




Notes.


Formula in REPORT::C2 can be filled down.


Currently boundaries of date range are inclusive but the length threshold is not.


Date values in A:B are assumed to have time part being 00:00:00.


Table is built with Numbers v2.



Regards,

H



EDIT: fixed boundary condition

Feb 8, 2016 3:52 AM in response to P33DEE

HI PD,


Here's an extension to what Wayne has provided. The table set below contains TWO examples, one using the appointment durations in column B of the table "Data", the other using the 'durations' entered as numbers expressing the minutes and parts of minutes in column C of "Data." The entries in each column are the same length of time for the same date.

User uploaded file

Example 1:

Columns A and B of Data contain the date and duration in minutes and seconds of each appointment.

Columns A, B and C of Summary contain the start and end dates of the period in which the count is to take place, and the count of appointments in that period lasting more than one minute.

Column A of Minimum contains the minimum length of appointment to be included in the count.


The formula below is entered into Summary::C2, and filled down.

Summary::C2: =COUNTIFS(Data :: $A,">="&$A2,Data :: $A,"<"&$B2,Data :: B,">="&Minimum::A$2)


Example 2:

Columns A and B of Data contain the date and a number corresponding to the duration in minutes and fraction of a minute of each appointment.

Columns A, B and C of Summary contain the start and end dates of the period in which the count is to take place, and the count of appointments in that period lasting more than one minute.

Column B of Minimum contains the minimum length of appointment to be included in the count, expressed as a number indicating that length in minutes.


The formula below is entered into Summary::D2, and filled down.

=COUNTIFS(Data :: $A,">="&$A2,Data :: $A,"<"&$B2,Data :: C,">="&Minimum::B$2)


You wrote: "from a maintenance point of view I think it would be cleaner to use a constant."


Perhaps, providing you will never want to change that constant. If you do change the constant, then you will need ot edit every formula using that constant. If you use a cell reference to pick up the 'constant,' then hanging the constant means making a single change of the value in that one cell.


That said, the formulas are easy to change.


The formula in Summary, column C, which uses the Duration values in Data column B needs the change shown here. Change the formula in C2, then fill to other cells in the column (if needed).


=COUNTIFS(Data :: $A,">="&$A2,Data :: $A,"<"&$B2,Data :: B,">="&DURATION(,,,1))


The formula in Summary, column D, which uses the numeric values in Data column C needs the change shown here. Change the formula in D2, then fill to other cells in the column (if needed).


=COUNTIFS(Data :: $A,">="&$A2,Data :: $A,"<"&$B2,Data :: C,">="&1)

Regards,

Barry

Number of records between two dates that lasted longer than 1 minute

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.