+ Reply to Thread
Results 1 to 7 of 7

Count number of values, until the sum of underlying values meets condition

Hybrid View

  1. #1
    Registered User
    Join Date
    06-17-2013
    Location
    London, England
    MS-Off Ver
    MS 365 Subscription
    Posts
    7

    Post Count number of values, until the sum of underlying values meets condition

    I have the following problem.

    I have 1,000 units of stock in inventory and I need to know when I'm running out of stock.

    Over the next 12 weeks I'm forecasting to sell the following number of units (assuming I had unlimited stock):

    Week 1: 50
    Week 2: 50
    Week 3: 50
    Week 4: 50
    Week 5: 300
    Week 6: 300
    Week 7: 300
    Week 8: 400
    Week 9: 300
    Week 10: 200
    Week 11: 100
    Week 12: 50

    I'd like to get a formula that basically sums up the above values in an array, and stops when the sum exceeds the initial 1,000. then the formula spits out the count value, i.e. how many weeks where added up before the value exceeded 1,000. This would then tell me that I'm running out in 7 weeks from today (i.e. adding up the first 7 values gets you number bigger than 7).

    Not sure if this is possible.

    Unfortunately I cannot do a helper column to calculate the cumulative value.

    Would be HIGHLY appreciated!

  2. #2
    Forum Expert
    Join Date
    01-25-2011
    Location
    Belgium, Alveringem
    MS-Off Ver
    Excel 2003, 2007, 365
    Posts
    1,419

    Re: Count number of values, until the sum of underlying values meets condition

    =min(if(sumif(b1:b12,"<="&row($b$1:$b$12),c1:c12)>=g1,row($b$1:$b$12),999))
    it's a matrixformula, so Shift+CTRL+Enter if your version >2019
    Attached Files Attached Files
    Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

  3. #3
    Registered User
    Join Date
    06-17-2013
    Location
    London, England
    MS-Off Ver
    MS 365 Subscription
    Posts
    7

    Re: Count number of values, until the sum of underlying values meets condition

    Thanks for the quick response. my data is actually organized horizontally, so values are in A1, B1, C1 etc.

    how would the formula have to be amended to work in that format?

    Thanks a lot in advance!

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,492

    Re: Count number of values, until the sum of underlying values meets condition

    Which latest version do you have? Excel 2019 or the MS365 subscription? Please clarify in your profile. Thanks.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,194

    Re: Count number of values, until the sum of underlying values meets condition

    Something like:
    Formula: copy to clipboard
     =MIN(IF(SUMIF(C2:N2,"<="&COLUMN($C$2:$N$2),C3:N3)>=D16,COLUMN($C$2:$N$2),999))
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  6. #6
    Forum Expert
    Join Date
    01-25-2011
    Location
    Belgium, Alveringem
    MS-Off Ver
    Excel 2003, 2007, 365
    Posts
    1,419

    Re: Count number of values, until the sum of underlying values meets condition

    =min(if(sumif(a1:z1,"<="&$a$1:$z$1,d3:ac3)>=e7,$a$1:$z$1,999))
    made for 26 weeks with the values starting in D3:AC3 and the values 1 to 26 in A1:Z1
    Attached Files Attached Files
    Last edited by bsalv; 09-26-2021 at 05:07 PM.

  7. #7
    Forum Expert
    Join Date
    01-25-2011
    Location
    Belgium, Alveringem
    MS-Off Ver
    Excel 2003, 2007, 365
    Posts
    1,419

    Re: Count number of values, until the sum of underlying values meets condition

    almost the same formula, but your numbers start now in A1, B1, ..., Z1 (only other cellreferences)
    Somewhere in you sheet, you have that yellow row 1 to 26
    Attached Files Attached Files

+ 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. Auto Populate values if it meets condition
    By omer.nazish in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-30-2018, 07:45 AM
  2. [SOLVED] Sum top 30 highest values if meets condition
    By beeko in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 04-07-2017, 11:28 AM
  3. Finding (and using cell values from) underlying Row Number of a Clicked Button
    By xlguy in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-17-2015, 09:04 AM
  4. [SOLVED] Count unique values if adjacent cell meets criteria
    By chococ in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 05-01-2014, 04:13 AM
  5. [SOLVED] Count values in a range if adjacent cell meets a particular criteria
    By DougC in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-22-2013, 03:12 PM
  6. Replies: 2
    Last Post: 03-26-2013, 12:54 PM
  7. Count unique values in a column for each row that meets 3 criteria
    By xtomg19 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-18-2012, 12:15 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