Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.misc,microsoft.public.excel.worksheet.functions
John
 
Posts: n/a
Default Calculating time between values (tricky Problem)

Bernard that worked great! If you do get a chance to
make a VBA function let me know as that would be a lot
easier and cleaner then trying to do the helper
columns. Thank you for all your help! I really
appreciate it.

Best regards,
John

"Bernard Liengme" wrote in message
...
Let the dates be in A1:A28 with the 1/0 in B1:B28.
I have ignored the last two data lines since we have hit the end of a
'cycle'

I got my answer with two helper columns; it could be done with one but two
makes for easier explanation.
In C2 (the SECOND row) use =AND(B1=0,B2=1) and copy down the column
Note the groups of FALSE, there are groups of 8, 8, 7.
Compare this to your values 9,9,8 (we are 1 out in each case)
As I want to do arithmetic I need to get numbers, so in D2 use =NOT(C2)*1
This gives 0 when C is TRUE and 1 when C is FALSE
We have groups of 8, 8, and 7 values of 1, each separated by 0
Now to average the data: we want to count the 1's but we need to add an
additional 1 for very group. Recall every group ends with a 0.
The average is given by =(SUM(D2:D28)+COUNTIF(D3:D28,0))/COUNTIF(D3:D28,0)
The numerator add the 1's and then adds 1 for every zero in the range
AFTER THE FIRST ZERO (so it is D3:D28 not D2:D28)
The COUNTIF also tells how many groups we have. So we get the average size
of each group.
I suspect there is a more sophisticated way but that's my contribution.
If I have time today I will try to code a VBA function
best wishes
--
Bernard V Liengme
www.stfx.ca/people/bliengme
remove caps from email

"John" wrote in message
...
I am trying to calculate the average time between starting 1's. The data
has a date which is every day and a 1 or 0 next to it. When the data goes
from 0 to 1 I want to start counting until I find the next 1 that follows
a 0. Once I have all those days between starting 1's I want to find the
average days between starting 1's. I have a dataset that looks like the
following:

08/04/05 0
08/05/05 1
08/06/05 1
08/07/05 1
08/08/05 1
08/09/05 0
08/10/05 0
08/11/05 0
08/12/05 0
08/13/05 0
08/14/05 1
08/15/05 1
08/16/05 1
08/17/05 0
08/18/05 0
08/19/05 0
08/20/05 0
08/21/05 0
08/22/05 0
08/23/05 1
08/24/05 1
08/25/05 1
08/26/05 1
08/27/05 0
08/28/05 0
08/29/05 0
08/30/05 0
08/31/05 1
09/01/05 1
09/02/05 0

So for the above example the days between starting 1's is 9,9, and 8. The
average would be (9+9+8)/3 = 8.67.

Is there a way to get the above using a Formula or would it need to be
done in VBA code?

Best regards,
John



---
avast! Antivirus: Outbound message clean.
Virus Database (VPS): 0612-4, 03/25/2006
Tested on: 3/27/2006 8:02:02 AM
avast! - copyright (c) 1988-2005 ALWIL Software.
http://www.avast.com







Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculating Time Paul Cooke Excel Discussion (Misc queries) 4 December 1st 05 07:51 PM
Time calculation problem (URGENTProject due) g6pack Excel Discussion (Misc queries) 4 November 28th 05 04:14 AM
Calculations from date and time values kp Excel Worksheet Functions 7 November 27th 05 08:07 PM
Calculating time difference over midnight! sygazelle Excel Discussion (Misc queries) 4 September 29th 05 04:59 PM
More time questions and IF function problem baz Excel Worksheet Functions 6 June 17th 05 08:56 PM


All times are GMT +1. The time now is 11:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"