+ Reply to Thread
Results 1 to 14 of 14

Parse Data in two hour blocks

  1. #1
    Registered User
    Join Date
    09-21-2013
    Location
    TX
    MS-Off Ver
    2010
    Posts
    10

    Parse Data in two hour blocks

    I have data which looks like

    9/3/2013 5:38:14 13
    9/3/2013 5:38:35 13
    9/3/2013 5:42:47 13
    9/3/2013 5:46:59 14
    9/3/2013 5:52:14 14
    9/3/2013 5:56:26 15
    9/3/2013 5:59:35 15
    9/3/2013 6:00:59 14
    9/3/2013 6:06:16 14
    9/3/2013 6:11:08 14
    9/3/2013 6:13:35 14
    9/3/2013 6:16:44 14


    The logs are generated daily, so the first column is irrelevant at the moment.
    What I want to do is to generate an average for the third column in two hour blocks. In other words, what was the average number in the third row (C) between 4:00:00 and 6:00:00. I would want a report and do that for each two hour period.

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Parse Data in two hour blocks

    Hi and welcome to the forum

    Based on your sample data, in A2:C13, try this (this will also be your report).

    Create a table of times, with 2 hour intervals...
    Time
    2:00
    4:00
    6:00
    8:00
    10:00
    12:00
    14:00
    16:00
    18:00
    20:00
    22:00
    then in the next column (I used G and G for this), copy this down...
    =IFERROR(AVERAGEIFS($C$2:$C$13,$B$2:$B$13,">="&F1,$B$2:$B$13,"<"&F2),"")
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    09-21-2013
    Location
    TX
    MS-Off Ver
    2010
    Posts
    10

    Re: Parse Data in two hour blocks

    Sorry, I guess I didn't explain that we will not know the number of entries in each two hour block. Either that or I am misreading your formula.

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Parse Data in two hour blocks

    Hi wilburr and welcome to the forum,

    I've created a sample workbook for you with random times. I included a Helper Column with an MRound formula in it to round to the closest 2 hour and then did a Pivot Table using the data that easily shows the Average of the times included in each group. I think that is what you want. See if my sample helps.
    Attached Files Attached Files
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Parse Data in two hour blocks

    You dont need to know how many entries will be in each block, if you create the table as I suggested, and use the formula provided, it will calc the averages for each block...
    A
    B
    C
    1
    2
    9/3/2013
    5:38:14
    13
    3
    9/3/2013
    5:38:35
    13
    4
    9/3/2013
    5:42:47
    13
    5
    9/3/2013
    5:46:59
    14
    6
    9/3/2013
    5:52:14
    14
    7
    9/3/2013
    5:56:26
    15
    8
    9/3/2013
    5:59:35
    15
    9
    9/3/2013
    6:00:59
    14
    10
    9/3/2013
    6:06:16
    14
    11
    9/3/2013
    6:11:08
    14
    12
    9/3/2013
    6:13:35
    14
    13
    9/3/2013
    6:16:44
    14


    G
    H
    2
    2:00
    3
    4:00
    13.85714
    4
    6:00
    14
    5
    8:00
    6
    10:00
    7
    12:00
    8
    14:00
    9
    16:00
    10
    18:00
    11
    20:00
    12
    22:00

  6. #6
    Registered User
    Join Date
    09-21-2013
    Location
    TX
    MS-Off Ver
    2010
    Posts
    10

    Re: Parse Data in two hour blocks

    FDibbins

    Would you send me a copy of the file with your working formula? I pasted you formula into the spreadsheet and saw no output and did not receive an error message.

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Parse Data in two hour blocks

    sure, see the attached There will not be an error message, because part of the formula takes care of errors
    Attached Files Attached Files

  8. #8
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Parse Data in two hour blocks

    self-deleted duplicate post

  9. #9
    Registered User
    Join Date
    09-21-2013
    Location
    TX
    MS-Off Ver
    2010
    Posts
    10

    Re: Parse Data in two hour blocks

    I see how this works now, but I have a problem. I use the formula. It calculates the value. Everything looks good. I close the spreadsheet and reopen it later. Everything still looks good but the formula is gone.

    I have gone back and checked. The formula is still there when the results are returned, but not after I close and reopen the file. Thoughts?

  10. #10
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Parse Data in two hour blocks

    wow that is wierd, all I can think of is that you didnt save the file before you closed it?

  11. #11
    Registered User
    Join Date
    09-21-2013
    Location
    TX
    MS-Off Ver
    2010
    Posts
    10

    Re: Parse Data in two hour blocks

    No, the results remain, just the formula is gone. Not just yours, simple average formulas show the same pattern.

  12. #12
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Parse Data in two hour blocks

    Any chance of seeing the actual workbook? If it contains sensitive info, dont post here

  13. #13
    Registered User
    Join Date
    09-21-2013
    Location
    TX
    MS-Off Ver
    2010
    Posts
    10

    Re: Parse Data in two hour blocks

    I think it is attached. I am new to the forum.
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    09-21-2013
    Location
    TX
    MS-Off Ver
    2010
    Posts
    10

    Re: Parse Data in two hour blocks

    I think I found the problem. The data comes in as a csv. The formula works in the csv, but not when saved as a csv. Now I add the formula, save as excell and the formula sticks.

    Thanks for all of your help!

  15. #15
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Parse Data in two hour blocks

    Based on your last post in this thread, its apparent that you are satisfied with the solution(s) you've received and have solved your question, but you haven't marked your thread as "SOLVED". I will do it for you this time.

    In future, to mark your thread as Solved, you can do the following -
    Select Thread Tools-> Mark thread as Solved.

    Incase your issue is not solved, you can undo it as follows -
    Select Thread Tools-> Mark thread as Unsolved.

    Also, since you are relatively new to the forum, i would like to inform you that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post which helped you. This adds to the reputation of the person who has taken the time to help you.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Charting Y-Values by Hour Blocks
    By kelman17 in forum Excel Charting & Pivots
    Replies: 7
    Last Post: 06-18-2013, 12:16 AM
  2. [SOLVED] Grouped Data Blocks editted to Columns of Data based off left cell value?
    By BlazzedTroll in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 06-10-2013, 03:06 PM
  3. [SOLVED] Stuck on how to Reformat data blocks into list with only essential data
    By bnasty in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-27-2012, 04:32 PM
  4. Using macros to identify blocks of data and summarise those blocks
    By gophbeav in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-05-2012, 04:35 AM
  5. Sort blocks of data
    By WasWodge in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-20-2012, 04:44 PM

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