+ Reply to Thread
Results 1 to 8 of 8

Chart events/incidents by day of week and time

  1. #1
    Registered User
    Join Date
    04-22-2016
    Location
    New Jersey
    MS-Off Ver
    365
    Posts
    31

    Chart events/incidents by day of week and time

    Hello Group - I am fairly new to excel, but I appreciate it's capability. I will be maintaining a sheet that includes the date and time of an incident. I would like to visually display trends. How often does the incident occur on Monday vs. Tuesday vs. Wednesday and so on. I also want to display the times of occurrence. This would allow me to project the hottest and coldest days incidents occur along with hottest and coldest times incidents occur. This will be a living document, meaning I would like to update it daily to track changes. Can someone help?

    Thanks

  2. #2
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Chart events/incidents by day of week and time

    It would help a lot if you include a sample file. It looks like what you want to do is a histogram. This can be made dynamic. A lot depends on what the source data looks like. The solution will probably involve excel tables (only because they know how many rows they have so any formulas based on them deal with exactly the amount of data they need) and probably a couple of helper cells to put times into "buckets" for plotting.

    Here is some information on Excel Tables: http://www.utteraccess.com/wiki/inde...ables_in_Excel

    Come back with a sample spreadsheet, and I'm sure someone will jump in to help.
    One spreadsheet to rule them all. One spreadsheet to find them. One spreadsheet to bring them all and at corporate, bind them.

    A picture is worth a thousand words, but a sample spreadsheet is more likely to be worked on.

  3. #3
    Registered User
    Join Date
    04-22-2016
    Location
    New Jersey
    MS-Off Ver
    365
    Posts
    31

    Re: Chart events/incidents by day of week and time

    Thank you for the quick response. I hope this information makes it a little more clear. The spreadsheet attached provides the incident, incident date, and incident time. Again, I am looking for a way to graphically display trend analysis. What day and at what time are the incident occurring.
    Attached Files Attached Files

  4. #4
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Chart events/incidents by day of week and time

    Here is what I did. First I made the data into an Excel Table so that when you add new data, it automatically becomes part of the table and all the formulas that reference the table still work: they don't have to be changed.

    The first task was to separate the times into “buckets.” I decided on 4 hour buckets. If you want something else, you can adjust the formula. To separate the time into 4-hour chunks, I used the formula =MROUND([@[incident time]],240/1440). There are 1440 minutes in a day, and I want to take them in 240 minute (4 hours) increments. MROUND (N,X) rounds N to the nearest increment of X.

    Then I got the Weekday using the formula =WEEKDAY([@[incident date]]). This gives 1 for Sunday through 7 for Saturday.

    I then made a composite: =[@Weekday]+[@Time]. Time is always less than 1 (since it is only part of a whole day) so theses numbers cycle from 1 to 7 and start back with 1.

    Column H is for cosmetic purposes. We’ll get to it in a moment.

    Columns L and M are where most of the work is done.

    In Column L, I enumerated every 4 hours from Sunday Midnight 1 12AM to Saturday evening 7 8 PM

    Column M has the formula: =COUNTIFS(Table_Data[Composite],L3) which counts the number of times an incident fell into the bucket.

    Column K is cosmetic. =L3-INT(L3) this formula gets the time part for the bucket.

    Column J is cosmetic. =IF(INT(L2)<>INT(L3),INDEX($H$2:$H$8,INT(L3),1),"") this formula gets the day part of the bucket and looks up what day of the week it is. To keep the chart from getting too cluttered, I only want to show the day once and not for every hour.

    I then plotted J3:K44 and L3:L44.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    04-22-2016
    Location
    New Jersey
    MS-Off Ver
    365
    Posts
    31

    Re: Chart events/incidents by day of week and time

    dflak - You have no idea how grateful I am. This is exactly what I need. I assume this was childs play for you, but I spent a week trying to do this. I guess the only two questions I would have remaining are:
    a.) Is it easy to change the graphic to perhaps a scatter plot or a pie graph (purely inquisitive), I do not want to damage the sheet by messing with your formulas
    b.) I am pleased with the four hour blocks of time. But, for trend purposes, down the road if I want to change those to blocks, is that difficult?

    No rush on the answers, you have made my day.

  6. #6
    Registered User
    Join Date
    04-22-2016
    Location
    New Jersey
    MS-Off Ver
    365
    Posts
    31

    Re: Chart events/incidents by day of week and time

    dlak - Hello - I want to thank you again for the assistance. After using the sheet for a while this morning, I realized there was an issue. For some reason, the bar chart does not match the incidents on the table. I have attached the most recent example for you to see. There are only 80 incidents charted but a total of 93 on the table. Am I missing something?
    Attached Files Attached Files

  7. #7
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Chart events/incidents by day of week and time

    There is a rounding issue. MROUND and adding 240/1440 are not coming out to the same number. One is coming out 6.333333333333330 the other is coming out 6.333333333333340. I changed the formulas to use Time(4,0,0) instead of 240/1440 and I get the same results.

    I fixed the issue by truncating both values to 10 decimal places. I needed an additional helper column to make this work. The new column is column M and the countif formula works off it. You can hide columns L and N.

    To change to some other time interval, In column D change this formula: =MROUND([@[incident time]],TIME(4,0,0))

    In column L, change this formula: =L3+TIME(4,0,0) and extend it down as well as the formulas in columns N, J and K

    You will also have to change the ranges that the chart references.
    Attached Files Attached Files
    Last edited by dflak; 05-02-2016 at 03:40 PM.

  8. #8
    Forum Expert dflak's Avatar
    Join Date
    11-24-2015
    Location
    North Carolina
    MS-Off Ver
    365
    Posts
    7,920

    Re: Chart events/incidents by day of week and time

    I changed another formula. The composite is =TRUNC(IF([@Weekday]+[@Time]>=8,1,[@Weekday]+[@Time]),10). What was happening is that MROUND was taking late Saturday evening hours and rounding them to the 8th day. I "recycled" it to midnight Sunday.

+ 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] Counting incidents within time interval
    By Fritz1727 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-14-2015, 08:04 AM
  2. Replies: 2
    Last Post: 03-24-2015, 09:05 PM
  3. [SOLVED] VBA strange behavior On time events firing at unexpected time intervals.
    By Kramxel in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-04-2014, 05:58 AM
  4. Chart previous week data as grouped and current week as ungrouped
    By r_a_c_a_4_u in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-17-2013, 12:55 PM
  5. Replies: 4
    Last Post: 10-18-2012, 06:07 AM
  6. Chart two events over time
    By darbid in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 11-10-2008, 07:35 AM
  7. [SOLVED] enabling chart events for an embedded chart
    By Wazooli in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-26-2006, 09:20 AM

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