• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Sum based on condition

ardrianz

New Member
Hi
I would like to request your help in creating excel formula for the following 2 scenarios:
1. Number of consecutive months in which the value was above 3000. Also, the sum of the values of first 3 consecutive months of 3000 or above along with the month in which it was completed
2. Sum of the values each month above 50 or more - if the value falls below 50 in any month then there should be no further addition to the total.

Please find attached the workbook containing the details.

Thank you.
 

Attachments

  • Workbook.xlsx
    10.7 KB · Views: 10
Not sure if a formula can help here.
May be try writing a macro - look through cell, checking values and performing your desired action.
 
I can obtain the values you quote but it is by using an Excel version you are unlikely to have access to and functions that are still only available to insider beta subscribers. Might not be seen as terribly useful!
Consecutive months:
Code:
= LET(
   threshold, 3000,
   consecMonths, SCAN(0, value, LAMBDA(consec, v, IF(v>=threshold, consec+1, 0))),
   MAX(consecMonths))
Balance from 3rd consecutive month
Code:
= LET(
   threshold, 3000,
   consecMonths, SCAN(0, value, LAMBDA(consec,v, IF(v>=threshold, consec+1, 0))),
   balance, SCAN(0, value, LAMBDA(consec,v, IF(v>=threshold, consec+v, 0))),
   XLOOKUP(3, consecMonths, balance))
3rd consecutive month:
Code:
= LET(
   threshold, 3000,
   consecMonths, SCAN(0, value, LAMBDA(consec,v, IF(v>=threshold, consec+1, 0))),
   XLOOKUP(3, consecMonths, month))
Final balance for 3rd month or following:
Code:
= LET(
   threshold, 50,
   consecMonths, SCAN(0, value, LAMBDA(consec,v, IF(v>=threshold, consec+1, 0))),
   balance, SCAN(0, value, LAMBDA(consec,v, IF(v>=threshold, consec+v, 0))),
   XLOOKUP(MAX(consecMonths), consecMonths, balance))
 

Attachments

  • Workbook.xlsx
    10.7 KB · Views: 5
Thank you Peter. As you have mentioned, these formulas are not featuring in my MS Excel version (Office 365) so I am not able to implement it.
But thank you once again for your time and your inputs.
 
Back
Top