+ Reply to Thread
Results 1 to 8 of 8

Count periods where threshold is exceeded

  1. #1
    Registered User
    Join Date
    03-20-2009
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    7

    Count periods where threshold is exceeded

    Hi all
    I am trying to find a way to identify the nmber of periods where a particular value is exceeded.

    Basically I have daily data on sales for 40 years and I would like to define a level of sales i.e. 23 units per day and a period i.e. 10 days and then output the number of times where the recorded sales level is greater than 23 units per day for 10 or more days.

    Ideally I would like it so the sales level and period can be set in reference cells and the formula can adapt to different sales levels and periods.

    The data is formatted as follows:
    Date number of sales
    01/01/1990 15
    02/01/1990 16
    03/01/1990 12

    If anyone has any idea how to do this I would be very grateful!
    Last edited by dieter99; 04-05-2009 at 10:22 AM.

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Count periods where threshold is exceeded

    With
    A2:A1000 containing consecutive dates
    and
    B2:B1000 containing units sold per day

    ...and...
    E2 containing the consecutive days parameter...eg 10
    F2 containing the units threshhold....eg 23

    This ARRAY FORMULA, committed with CTRL+SHIFT+ENTER
    (instead of just ENTER),returns the number of times there were
    sales of more than 23 units for 10 or more consecutive days

    Please Login or Register  to view this content.
    Does that help?
    Last edited by Ron Coderre; 03-20-2009 at 10:38 PM. Reason: tweaked parameter from >10 days to >=10 days
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Registered User
    Join Date
    03-20-2009
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Count periods where threshold is exceeded

    That's great, you're now my new favourite person!

    Just to clarify, to compute the opposite i.e. the number of times there were
    sales of less than 23 units for 10 or more consecutive days the array would be this
    Please Login or Register  to view this content.
    Last edited by dieter99; 03-25-2009 at 12:54 AM. Reason: can't spell!

  4. #4
    Forum Expert
    Join Date
    06-18-2004
    Location
    Canada
    MS-Off Ver
    Office 2016
    Posts
    1,474

    Re: Count periods where threshold is exceeded

    That's correct. However, if the data can contain empty cells, the formula may need to be modified.

    Hope this helps!

    xl-central.com

  5. #5
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Count periods where threshold is exceeded

    Domenic is correct. Blank cells would need to be addressed.

    Here's one option:
    ARRAY FORMULA

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    03-20-2009
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Count periods where threshold is exceeded

    Quote Originally Posted by Ron Coderre View Post
    Domenic is correct. Blank cells would need to be addressed.

    Here's one option:
    ARRAY FORMULA

    Please Login or Register  to view this content.
    Thanks for that addition, I did have missing data but I knew it was a linear progression between data values so used a vb script to interpolate between the values. This caused the answers from the formula I posted to be slightly wrong, but now I can use the irregular data it works perfectly.

    Many thanks, I would never have figured this out in a million years!

  7. #7
    Registered User
    Join Date
    03-20-2009
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Count periods where threshold is exceeded

    So I had the formula's working perfectly and a colleague asked me to look at a different data set so I pasted this in and now the array formula's now both return 1 under all conditions. I have not changed anything in the formula's, merely pasted in continuous (no blanks) data.

    I cannot spot what has gone wrong. I've attached a sample from the data, to check the array, I set the time period to 1 and compare the answer to a simple countif formula that counts the number of exceedances of the threshold value.

    Can anybody shed some light?!
    Attached Files Attached Files

  8. #8
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Count periods where threshold is exceeded

    Your sample data is in descending order, begins at 125.00 and ends at 75.22.
    Both formulas are structured to return the number of times that
    groups of consecutive values exceed a threshhold.

    The H6 formula is counting the number of times the value is
    greater than 121.6 for 1 or more days. In your data, only the
    first 9 values are greater than 121.6. All other values are
    less than or equal to 121.6. Consequently, you have 1 group
    of consecutive values that satisfies the criteria.

    The H9 formula is counting the number of times the value is
    less than 77.5 for multiple days. In your data, only the
    last 153 values are less than 77.5. That 1 group of consecutive
    values satisfies the criteria.

    Both formulas are returning what they are designed to return.
    In these cases: 1.

    If you copy B2 into B25...that will constitute another event
    and H6 will return: 2

    Does that help?

+ 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