+ Reply to Thread
Results 1 to 5 of 5

Frequency distribution

Hybrid View

  1. #1
    Registered User
    Join Date
    08-28-2017
    Location
    Poland
    MS-Off Ver
    2016
    Posts
    2

    Frequency distribution

    Hi

    I have a worksheet with data (ACTIVITY, START_DATE, END_DATE). I will have 10 000 records. I need to do a table with time intervals (00:01-00:15, ... , 23:45-23:59) with frequency of my data. For example: 00:01-00:15 - 5 activities , 00:16-00:30 - 3 activities etc. Activities may by long and include in several time intervals.

    I attach worksheet and please help.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    05-01-2014
    Location
    California, US
    MS-Off Ver
    Excel 2010
    Posts
    1,795

    Re: Frequency distribution

    Sorry, no time to answer your primary question.

    But be careful with how you generate the limits ("bins") for the frequency table, A2:A98 in your example file. Despite appearances (due to Excel formatting limitations), most of those times (55 of 97) are infinitesimally less than how they appear.

    As a consequence, for example, if you select two vertical cells (e.g. H16:H17) and array-enter (press ctrl+shift+Enter instead of just Enter) =FREQUENCY(TIME(3,30,0),A16:A17), the count (1) will correspond to 3:45 (H17) instead of 3:30 (H16).

    I presume that you generated A4:A97 by writing something like =A3+TIME(0,15,0), then copy-and-pasted-value.

    Instead, write =--TEXT(A3+TIME(0,15,0),"[h]:m").

    The double negate ("--") converts text into a numeric value. The TEXT function effectively rounds the calculation to the minute with the same internal binary representation as the equivalent constant. The "[h]" specification would show hours 24 and greater. Even though that is not necessary in this table, it is "good practice" to get into the habit of doing for calculated times that you want to display in hours.

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    27,044

    Re: Frequency distribution

    [initial response deleted]

    After looking at your data, I don't think your question is well-formulated. You have activities with a Start and Stop time. For a given interval, what you do want to count?

    The number of activities that start in that interval
    The number of activities that end in that interval
    The number of activities that have any portion of time in that interval

    For questions like this it's always helpful to include a sample of what you want the result to be.
    Last edited by 6StringJazzer; 08-28-2017 at 03:36 PM.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  4. #4
    Registered User
    Join Date
    08-28-2017
    Location
    Poland
    MS-Off Ver
    2016
    Posts
    2
    I would like to count The number of activities that have any portion of time in that interval



    Quote Originally Posted by 6StringJazzer View Post
    [initial response deleted]

    After looking at your data, I don't think your question is well-formulated. You have activities with a Start and Stop time. For a given interval, what you do want to count?

    The number of activities that start in that interval
    The number of activities that end in that interval
    The number of activities that have any portion of time in that interval

    For questions like this it's always helpful to include a sample of what you want the result to be.

  5. #5
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,477

    Re: Frequency distribution

    In the spirit of divide and conquer, here's how I developed what appears to be a workable solution:

    1) As much as I might have liked to use the FREQUENCY() function, with some of the anticipated other steps along the way, I decided that the COUNTIFS() function would be more useful. Can I assume you are familiar with the COUNTIFS() function (https://support.office.com/en-us/art...c-aa8c2a866842 )? Once I had chosen the COUNTIFS() function as my desired function, everything else seemed like the underneath problem (not necessarily Excel specific) of figuring out the logic needed to correctly count each entry.
    2) First step seemed to be to count how many start times are after each time interval. COUNTIFS(start_times,"<="&time_interval) (replace text with appropriate references, and pay attention to relative and absolute references so that the formula will be easy to copy).
    3) The other half of the count is determining how many end times are before a given time interval (a similar COUNTIFS() function to the previous).
    4) The actual count you want is to count all of those that start after the time interval, and then remove those that ended before the time interval -- effectively (result of step 2)-(result of step 3).
    5) That will fail to capture the "partial" time intervals, so I thought, if I can get the start_times to round down to the nearest 15 minutes and the end-times to round up to the nearest 15 minutes, I should be able to capture the partial intervals as well. The functions for these are the FLOOR() and CEILING() functions, so I added a couple of helper columns adjacent to the start and end times to perform these calculations. help file for FLOOR() function https://support.office.com/en-us/art...7-b0b4de5a8886 Ceiling function similar.
    6) Then, using these helper columns, instead of the original, as the inputs to steps 2 and 3, I think I got pretty close to what you want.

    It will be valuable to take joeu2004's comment about floating point rounding errors into consideration, as they could cause something to be miscounted.

    As one who hates trying to cram a lot into a single cell, I spread that calculation over several cells, and did not bother trying to nest it all into a single function. I expect it can be done, if needed, but I was too lazy to do it.

    Does that work? What part do you get stuck on?

    On edit: initially I think I had the inequality inverted in step 2. I think it is correct now, though, as soon as I start second guessing myself, I get lost in trying to decide. You may need to double check that part of the logic and make sure the inequality is pointed the right way.
    Last edited by MrShorty; 08-28-2017 at 05:00 PM. Reason: Wrong direction for inequality.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

+ 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. How to plot frequency distribution graph with 2 distribution plots
    By escpolina in forum Excel Charting & Pivots
    Replies: 18
    Last Post: 08-16-2017, 10:22 AM
  2. Unbind a frequency distribution
    By AGSwift in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-13-2017, 02:29 PM
  3. [SOLVED] Frequency Distribution Example Question
    By zanshin777 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-27-2015, 04:22 PM
  4. Histogram from frequency distribution?
    By fluffyemu in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 02-19-2012, 07:02 AM
  5. Frequency distribution and histogram
    By case in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-22-2010, 08:42 PM
  6. Frequency distribution
    By Ms MIS in forum Excel General
    Replies: 1
    Last Post: 04-06-2005, 01:06 PM
  7. Sorting - Frequency distribution.
    By Stats guru in forum Excel General
    Replies: 2
    Last Post: 04-04-2005, 12:16 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