+ Reply to Thread
Results 1 to 38 of 38

Counting time

  1. #1
    Registered User
    Join Date
    07-01-2010
    Location
    Cleveland, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    36

    Counting time

    I have an issue with being able to count time on Excel. I have numerous data that start at various times nad I"m converting all of it to total seconds, so therefore i'm only using seconds. The equation I have is as follows. For the first number in in the series the equation is,=IF(A2>=0,1), then followed by =IF(A3=A2,H2,IF(A3=0,H2+1,IF(A3>=1,A3-A2+H2,H2+1))). But this doesn't work for every case, meaning, I sometimes go from 57,58,59,0,2,3,4. And I can't figure out a equation to represent all, also, Sometimes i have 34,35,37,0,39 where data is lost, and I need to account for that too. So basically i'm just looking for a way to add up all the seconds.

    EDIT: also if it's the same second, I need to eb the same as the previous hence the first part of my equation (A3=A2, H2)

  2. #2
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Counting time

    To best describe or illustrate your problem you would be better off attaching a dummy workbook, the workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.

    If needed supply a before and after sheet in the workbook so the person helping you can see what you are trying to achieve.

    Doing this will ensure you get the result you need!


    Also, please check your posts for typos, because it's not entirely clear to me whether some of the characters you typed above are intended to be there or not. For example, I don't know what to make of this:

    I need to eb the same as the previous
    .... and from the data quality of your post I can't assume that anything that you typed about your data can be taken at face value.

  3. #3
    Registered User
    Join Date
    07-01-2010
    Location
    Cleveland, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: Counting time

    sorry about that i was attemping to make data.
    Attached Files Attached Files

  4. #4
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Counting time

    i cant understand that at all! also why are you array entering formula?
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  5. #5
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372

    Re: Counting time

    Can you spell out the rules for your expected results in plain words?

    The only difference between your (expected) column C and (calculated) column B seems to be in row 50. What are you expecting to see based on which rules?

  6. #6
    Registered User
    Join Date
    07-01-2010
    Location
    Cleveland, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: Counting time

    i want to add up the time, the time repeats over and over. IE you could have the same data continuing 300 times, but I need it to ALL add up. to a TOTAL time in seconds.But the problem is those formulas don't always work. I honestly don't know how to be much clearer then that. ADD up the TIME. so in row 50, where it starts back at 0 it's going to go BACK up to 59 then back to 0 then back to 59 then back to 0. make sense? I need it to just add up, but sometimes data is collected within the same second so it doesn't count as a new second IE row 14 & 15 they are counted in the total time as apart of the SAME second. If this still doesn't make sense. I honestly have no idea what else to say.

    EDIT: to answer what i expect to see...

    i'm expecting if the time counting is equal to the previous one IE row 14 & 15 they should be counted as the same second in total time, if a 59 is followed by a 0 or 1 or 2 etc it is added to it's total time. IE rows 48-51. If there is a 0 in the data because of a loss of data, it should just be added to the previous second and counted to be counted. there is NO exact answer to what i expect, they will vary from every data set. I can't give you a specfic example for everything, because sometimes the data starts at 0 sometimes it starts at 45. It all varies.
    Last edited by TheGame0135; 07-13-2010 at 09:30 AM.

  7. #7
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Counting time

    Why not (starting in E3 dragged down)

    =IF(AND(ROW()>4,D3=E2,D2=0),E2,D3-D2+E2)

    That seems to give you your expected results. Yes?
    Last edited by ChemistB; 07-13-2010 at 09:58 AM.
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  8. #8
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Counting time

    Perhaps, in B3:

    Please Login or Register  to view this content.
    copied down?
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  9. #9
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Counting time

    Combining with ChemistB's solution:

    =IF(A3=0,LOOKUP(2,1/(A$2:A2<>0),B$2:B2)+1,B2+A3-A2)

    should work best.....

    Edit... I guest Chemist changed his solution....

  10. #10
    Registered User
    Join Date
    07-01-2010
    Location
    Cleveland, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: Counting time

    your guys formulas do work unless I have a 1 after a 59 then they don't work. It works for my example data set. But if you put a 1 in instead of one of hte 0's you'll see it doesn't work. I have to take into account that the data can change and hardly be the same multiple times.

    EDIT: if needed I can give you more data points. but they're basically repeating, it's just near the 55 second and 5 second (of the next minute) mark, where they screw up.

    EDIT: Also the first equation Chemist gave me doesn't work.
    Last edited by TheGame0135; 07-13-2010 at 10:44 AM.

  11. #11
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Counting time

    So if there is a 1 after the 59 should the number be 60 in the next cell?

  12. #12
    Registered User
    Join Date
    07-01-2010
    Location
    Cleveland, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: Counting time

    also if this helps, this equation USUALLY works, unless there is a 0 in between numbers like column D. =IF(A3=0,H2+1,IF(A3=1,H2+1,IF(A3=A2,H2,IF(A3-A2=A3,H2+1,A3-A2+H2))))...


    EDIT: disregard that last statement, if you place this equation into my created data you'll see it does NOT work. thanks.
    Last edited by TheGame0135; 07-13-2010 at 10:59 AM.

  13. #13
    Registered User
    Join Date
    07-01-2010
    Location
    Cleveland, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: Counting time

    in the Total time column yes NBVC. if the time (column A) goes 58 59 1 2 3 it would be (column B) 58 59 60 61 62. or 58 59 0 2 3 it would be 58 59 60 62 63 (it all depends on where it is in the timeline i if i'ts near 2 minutes it would be like this) 58 59 0 2 3 in column A and 118 119 120 122 123 in column B

  14. #14
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Counting time

    Is this any better?

    =IF(A3<A2,LOOKUP(2,1/(A$2:A2<>0),B$2:B2)+1,B2+A3-A2)

  15. #15
    Registered User
    Join Date
    07-01-2010
    Location
    Cleveland, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: Counting time

    it work unless there is a 0 thrown into hte middle of it. then it doesn't. try placing that into column E about column D and you'll see wha ti'm saying

  16. #16
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Counting time

    If I put 0's amidst, I get accumulation of seconds... so I am not understanding anymore your request....

  17. #17
    Registered User
    Join Date
    07-01-2010
    Location
    Cleveland, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: Counting time

    it also doesn't work if the data goes such as this... Column A: 0 49 50 51 51... it amkes Column B 0 50 51 52 52...

    EDIT: if you put the equation you just gave me into column E you'll see it jumps from 29 to 58.

  18. #18
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Counting time

    It would be suggested to update a better example showing a combination of things that could happen so that all bases are covered, in one column and in the next column, manually enter accurate expected results.

  19. #19
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Counting time

    if the time (column A) goes 58 59 1 2 3 it would be (column B) 58 59 60 61 62. or 58 59 0 2 3 it would be 58 59 60 62 63
    If going from 59 to 0 raises the value by 1, wouldn't going from 59 to 1 raise it by 2?

  20. #20
    Registered User
    Join Date
    07-01-2010
    Location
    Cleveland, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: Counting time

    yes Chemist that's a typo, i'm going to try to send a new sheet out sometime tonight, I just odnt have the time to do it at work.

  21. #21
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561

    Re: Counting time

    Can anyone please explain what we're actually trying to achieve?

    Something like:
    We start with the data in column (?) and want to achieve the expected results I demonstrated (manually) in column (?)
    If the value in (??) is (??) then the value in (??) needs to be (??+/-??)
    and If the value in (??) is (??) then the value in (??) needs to be (??+/-??)
    ...
    etc.

    ?
    CC


    If you feel really indebted please consider a donation to charity. My preferred charity is ActionAid but there are plenty of worthy alternatives.

  22. #22
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Counting time

    Okay, now explain "dropped data" to me. You gave the example of 34,35,37,0,39. That's different from when a number just "turns over", yes? (For example 59, 0, 1)
    What do you want when data is dropped? Fill in the following series
    Col A ...34, 35, 37, 0, 39... Col B: 45, 46, 48, ?, ?
    Thanks

  23. #23
    Registered User
    Join Date
    07-01-2010
    Location
    Cleveland, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: Counting time

    Quote Originally Posted by ChemistB View Post
    Okay, now explain "dropped data" to me. You gave the example of 34,35,37,0,39. That's different from when a number just "turns over", yes? (For example 59, 0, 1)
    What do you want when data is dropped? Fill in the following series
    Col A ...34, 35, 37, 0, 39... Col B: 45, 46, 48, ?, ?
    Thanks
    Chemist you are correct, What i'd like is for this

    Col A 34, 35, 37, 0, 39..
    Col B 45 46 48 49 50...

    does that make sense? i want the 0 to be represented but to NOT mess up the sequence. Because they times that it does turn over I need it to be represented as well make sense? But it also must be taken into account it doesn't ALWAYS have to be a 0 at hte "dropped data" it could be a 5, it could be any random number, it's just a number that DOESN'T make sense in the sequence, IE. it could go 34 35 37 123 39 or 34 35 37 54 39. this is using your example you provided.

  24. #24
    Registered User
    Join Date
    07-01-2010
    Location
    Cleveland, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: Counting time

    Quote Originally Posted by Cheeky Charlie View Post
    Can anyone please explain what we're actually trying to achieve?

    Something like:
    We start with the data in column (?) and want to achieve the expected results I demonstrated (manually) in column (?)
    If the value in (??) is (??) then the value in (??) needs to be (??+/-??)
    and If the value in (??) is (??) then the value in (??) needs to be (??+/-??)
    ...
    etc.

    ?
    Okay Charlie, if you look at the example I've provided. Start with Column A. This is time elapsed in seconds (so it resets after it gets to 59) I want to get hte results I demonstrated(manually) in column C. the if the value ones vary, IE if column A says, 34 35 36 0 38 I want Column C to say (if there had already been counting,) 45 46 47 48 49. If there is 2 of hte same number in column A then they should REPEAT the Column C number IE, if Column A says 34 35 36 36 37 39 then Column C should say 45 46 47 47 48 50. If there is an odd number (and odd as in a number that doens't fit the sequence such as: ) Column A 34 35 36 0 39 40 or (for Column A) 34 35 36 59 39 40. Column C should be 45 46 47 48 49 50 and 46 47 48 49 50 respectively. Again these numbers can do just about anything, and by anything i mean it could look like this... 0 0 0 49 50 51 52 53 54 55 59 0 1 2 3. That last string is assuming the first 3 0's are at the beginning of all my data. I hope this helps you guys to understand. I'm trying my best to explain it.

  25. #25
    Registered User
    Join Date
    07-01-2010
    Location
    Cleveland, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: Counting time

    ALSO a note to anyone trying to help, my example I provided is what I've been working with, It does work from time to time but the monkey wrenches that get thrown in (such as the 0 or random numbers) throw it off, Maybe by looking at it you can develop upon it further.

  26. #26
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Counting time

    Okay, next question, when do you determine that it's dropped data and not "turned over" data? i.e. where's the cutoff; 59, 58, 55, 50?

  27. #27
    Registered User
    Join Date
    07-01-2010
    Location
    Cleveland, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: Counting time

    Quote Originally Posted by ChemistB View Post
    Okay, next question, when do you determine that it's dropped data and not "turned over" data? i.e. where's the cutoff; 59, 58, 55, 50?
    well first, i'm going to try to be more specific about data, turned over data is just data that continued on to the next minute. There really is no specific cut off for dropped data. It could litterally happen anywhere, it's really more of WHERE the data dropped occured. IE if the time is 54 55 58 59 0 1 2 3 there is no dropped data this is just starting over with the next minute, if it's 54 0 58 59 0 1 2 3 you have a dropped data between 54-58 and a turned over data between 59-1. OR it could be like this... 54 55 58 59 0 1 2 3 34 4 in this case the dropped data is 34. it's a number that's in the sequence doesn't make sense. 34 seconds can't be between 3 & 4 make sense? the 0 is more likely to happen but I've seen numbers such as 5,6,7 that just make no sense as to where they are. I'm looking at a data sheet that has an elapsed time of 59 0 2 0 0 4. the 2 zeros in between 2 and 4 are dropped data. BUT they still need to be included in calcuations. THEREFORE, if this was counting the first minute into the 2nd minute it would be (COLUMN C) 59 60 61 62 62 64. make sense?

  28. #28
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Counting time

    Yes, it makes sense to me. I'm just trying to figure out how to explain it to Excel.

  29. #29
    Registered User
    Join Date
    07-01-2010
    Location
    Cleveland, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: Counting time

    lol thank you for making me feel less stupid. Explaining over the internet has been VERY difficult. and when trying to figure it out please remember the start can be anything too. IE. the count could start like this 0 0 0 49 50 51 53... because the seconds start with whatever time it is. Maybe this is an important key i left out? the seconds are according to time. I was trying to take the time of day and making it all one value so it would be easier to use. IE i took 2:30:45 and made it all into seconds with the FIRST spot starting at 1. hope that doesn't confuse you more.
    Last edited by TheGame0135; 07-13-2010 at 03:25 PM.

  30. #30
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Counting time

    Is there a typical range of seconds between readings? Maximum and minimum?

    So with 0 0 0 49 50 51 53
    would be be 1,1,1,50,51,52,54?

  31. #31
    Registered User
    Join Date
    07-01-2010
    Location
    Cleveland, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: Counting time

    Quote Originally Posted by ChemistB View Post
    Is there a typical range of seconds between readings? Maximum and minimum?

    So with 0 0 0 49 50 51 53
    would be be 1,1,1,50,51,52,54?
    no Chemist there is no type range, and no with what you have if Column A was 0 0 0 49 50 51 53 then column C would be 1 1 1 2 3 4 6

  32. #32
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561

    Re: Counting time

    Re dropped data:
    What if the numbers either side of the drop are not in order?
    You've explained:
    6,7,8,14,10 = 1,2,3,4,5

    but what about:
    6,7,8,14,9 = 1,2,3,?,?

    and:
    6,7,8,14,11=1,2,3,?,?

  33. #33
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Counting time

    perhaps if we tried to correct the wrong data first eg 13,25,16 replace with 13,0,16 as these should only be scattered about . then work on the resulting column instead?
    Attached Files Attached Files

  34. #34
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561

    Re: Counting time

    mdw,

    I like what you're doing but have two issues:

    1. Surely if the anomalies weren't 0s they'd be easier to tackle, as 0s aren't necessarily anomalous (as explained somewhere in this monster)?

    2. You test for and ( number > above, number > below ) but 13,14,3,16 is also an anomaly and is not already a zero

    Proposed alternative pending...

  35. #35
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Counting time

    i agree, if the data is garbage to start then it's going to be very difficult if not impossible to analyse properly.

  36. #36
    Registered User
    Join Date
    07-01-2010
    Location
    Cleveland, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: Counting time

    Quote Originally Posted by Cheeky Charlie View Post
    Re dropped data:
    What if the numbers either side of the drop are not in order?
    You've explained:
    6,7,8,14,10 = 1,2,3,4,5

    but what about:
    6,7,8,14,9 = 1,2,3,?,?

    and:
    6,7,8,14,11=1,2,3,?,?
    these cases it would be more like this...
    your 2nd case it would be 1, 2, 3,4,5 (9-8+4)
    3rd case is 1,2,3,4,7(11-8+4)


    they still count as a single point in time but the difference between the one following and hte one before have to be subtracted and added to it.

  37. #37
    Registered User
    Join Date
    07-01-2010
    Location
    Cleveland, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: Counting time

    Quote Originally Posted by martindwilson View Post
    perhaps if we tried to correct the wrong data first eg 13,25,16 replace with 13,0,16 as these should only be scattered about . then work on the resulting column instead?

    This doesn't work because when counting you need to start at 1 ( column B). It's just adding up to the total time in seconds. If you open my worksheet i submitted you can see what i've been doing, it does work a lot, but does'nt work all the time.

  38. #38
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561

    Re: Counting time

    Following on from mdw's good idea, OP, suggest you read the post again:

    =IF(AND(ABS(A2-A1-1)>3,ABS(A3-A2-1)>3),"anom",A2)

    ?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1