+ Reply to Thread
Results 1 to 7 of 7

Help with formula to find consecutive occurrences/duration of a situation(stockout)

  1. #1
    Registered User
    Join Date
    08-06-2015
    Location
    Pittsburgh, PA
    MS-Off Ver
    2010
    Posts
    6

    Help with formula to find consecutive occurrences/duration of a situation(stockout)

    I hope someone is able to help - really been going in circles on this one trying to figure out what to do. To give some background on my situation:

    I have 182 days of data for 500+ stores, and am tasked with finding of those 182 days, how many times inventory at the store level fell below 10 units. I have done a simple SUMIF for each line to find the # of times this occurred, but I also am looking to find the average time that a store stays below that level. So for instance, store #50 has had 60 days where stock was below 10 units. Of those 60 days, there were "stockout" durations of 10, 15, 5, 12, and 18 for an average period of 12 days.

    Is there a way/formula to get to where I am trying to go? Spent about 3 hours yesterday searching all through posts on here to no avail. I found a lot of information using FREQUENCY and the MAX functions but haven't had any luck getting to where i need to. Below is where i got(with the data from C41:GB41 for store #50

    =MAX(FREQUENCY(IF(C41:GB41<10,ROW(C41:GB41)),IF(C41:GB41>10,ROW(C41:GB41))))

    Thanks for any help that can be offered!!

  2. #2
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Help with formula to find consecutive occurrences/duration of a situation(stockout)

    You need to use the COLUMN function instead of the ROW function. Also, you're completely excluding any counts of 10.

    IF(C41:GB41<10
    IF(C41:GB41>10

    What if the count IS 10?

    Maybe you meant:

    IF(C41:GB41<10
    IF(C41:GB41>=10

    =MAX(FREQUENCY(IF(C41:GB41<10,COLUMN(C41:GB41)),IF(C41:GB41>=10,COLUMN(C41:GB41))))

    Still array entered.

    For the average, try this array formula**:

    =AVERAGE(IF(FREQUENCY(IF(C41:GB41<10,COLUMN(C41:GB41)),IF(C41:GB41>=10,COLUMN(C41:GB41))),FREQUENCY(IF(C41:GB41<10,COLUMN(C41:GB41)),IF(C41:GB41>=10,COLUMN(C41:GB41)))))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Registered User
    Join Date
    08-06-2015
    Location
    Pittsburgh, PA
    MS-Off Ver
    2010
    Posts
    6

    Re: Help with formula to find consecutive occurrences/duration of a situation(stockout)

    Tony,

    You are THE MAN. Thanks for the help on this - got me to exactly where I needed to be.

  4. #4
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Help with formula to find consecutive occurrences/duration of a situation(stockout)

    Quote Originally Posted by Tony Valko View Post
    For the average, try this array formula**:

    =AVERAGE(IF(FREQUENCY(IF(C41:GB41<10,COLUMN(C41:GB41)),IF(C41:GB41>=10,COLUMN(C41:GB41))),FREQUENCY(IF(C41:GB41<10,COLUMN(C41:GB41)),IF(C41:GB41>=10,COLUMN(C41:GB41)))))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.
    Improvement! This will only work in Excel 2007 and later.

    =AVERAGE(IFERROR(1/(1/FREQUENCY(IF(C41:GB41<10,COLUMN(C41:GB41)),IF(C41:GB41>=10,COLUMN(C41:GB41)))),""))

    Still array entered.

  5. #5
    Registered User
    Join Date
    08-06-2015
    Location
    Pittsburgh, PA
    MS-Off Ver
    2010
    Posts
    6

    Re: Help with formula to find consecutive occurrences/duration of a situation(stockout)

    Awesome! Thanks again Tony - very helpful, and the improvement is definitely shorter/less complicated and should allow for easier manipulation

  6. #6
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Help with formula to find consecutive occurrences/duration of a situation(stockout)

    You're welcome. Thanks for the feedback!


    If your question has been solved please mark the thread as being solved.

    In the menu bar above the very first post select Thread Tools, then select Mark this thread as solved.

  7. #7
    Registered User
    Join Date
    08-06-2015
    Location
    Pittsburgh, PA
    MS-Off Ver
    2010
    Posts
    6

    Re: Help with formula to find consecutive occurrences/duration of a situation(stockout)

    I was looking for that - couldn't seem to find it. good to go now

+ 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] Count Consecutive Occurrences
    By dlow in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-17-2014, 12:50 AM
  2. Replies: 0
    Last Post: 10-17-2013, 03:09 PM
  3. [SOLVED] Formula: To calculate duration between two times, if duration is over 6hours subtract 30mi
    By MattBarnes7 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-11-2013, 03:22 PM
  4. Replies: 12
    Last Post: 07-25-2012, 10:13 PM
  5. Count the number of consecutive occurrences
    By timmycl_7 in forum Excel General
    Replies: 12
    Last Post: 05-03-2012, 02:04 PM
  6. Find 4 consecutive occurrences
    By swatsp0p in forum Excel General
    Replies: 8
    Last Post: 03-27-2010, 01:55 PM
  7. counting the most consecutive occurrences
    By Reignman in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 03-12-2005, 05:56 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