+ Reply to Thread
Results 1 to 14 of 14

Summing up to a point

  1. #1
    Registered User
    Join Date
    03-03-2019
    Location
    Hong Kong
    MS-Off Ver
    Office 365
    Posts
    17

    Summing up to a point

    Hi guys,

    Short question. I have an array of values, returned by using filter function which is {20,30,40,10,60}. I would like to deduct 60 from this such that the output is {0,0,30,10,60}. Is there a way to do this? I was using scan and lambda function but residuals are accumulated. (Results were {0,0,30,40,100})
    Attached Files Attached Files
    Last edited by kohno71; 03-01-2022 at 09:38 AM.

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Summing up to a point

    I'm afraid I don't understand SCAN and LAMBDA... yet... but try:

    =LET(a,MMULT(N(SEQUENCE(ROWS(B2#))>=SEQUENCE(,ROWS(B2#))),N(+B2#))-SEQUENCE(5,,60,0),IF(a<0,0,a))
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  3. #3
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Summing up to a point

    or:

    =LET(d,B2#,r,ROWS(d),a,MMULT(N(SEQUENCE(r)>=SEQUENCE(,r)),N(+d))-SEQUENCE(r,,60,0),IF(a<0,0,a))
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    03-03-2019
    Location
    Hong Kong
    MS-Off Ver
    Office 365
    Posts
    17

    Re: Summing up to a point

    Thanks for the quick follow up. Unfortunately the output array isn't what I'm looking for. I would like to get {0,0,30,10,60}. Your formula returns the same as the scan/lambda output I have..

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

    Re: Summing up to a point

    Or:

    =LET(a,FILTER(A2:A6,A2:A6>0),IF(SCAN(C2,a,LAMBDA(x,y,x+y))<0,0,SCAN(C2,a,LAMBDA(x,y,x+y))))

    EDIT: Ignore! I misunderstood the requirement.
    Last edited by AliGW; 03-01-2022 at 08:52 AM.
    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.

  6. #6
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Summing up to a point

    Hahaha. Trying to do 3 things at once.... this is a mess... sorry... but the other 2 are going fine though (not Excel-related)!!

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

    Re: Summing up to a point

    Please explain why the third value should be 30.

  8. #8
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Summing up to a point

    (20+30+40)-60. From that point onwards.. return the value from column B.

  9. #9
    Registered User
    Join Date
    03-03-2019
    Location
    Hong Kong
    MS-Off Ver
    Office 365
    Posts
    17

    Re: Summing up to a point

    Yep , Thats why third value is 30. Its essentially FIFO (first in first out).

  10. #10
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Summing up to a point

    A bit convoluted... but:

    =LET(a,B2#,d,C2,b,SUBTOTAL(9,OFFSET(B2,,,SEQUENCE(ROWS(B2#))))+d,IF(b<0,0,IF(b<a,b,a)))

  11. #11
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Summing up to a point

    or, non-volatile:

    =LET(a,B2#,d,C2,b,MMULT(N(SEQUENCE(ROWS(B2#))>=SEQUENCE(,ROWS(B2#))),N(+B2#))+d,IF(b<0,0,IF(b<a,b,a)))
    Attached Files Attached Files

  12. #12
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Summing up to a point

    and of course, you can drop your incomprehensible SCAN/LAMBDA into that, too:

    =LET(a,B2#,d,C2,b,SCAN(d,a,LAMBDA(x,y,x+y)),IF(b<0,0,IF(b<a,b,a)))
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    03-03-2019
    Location
    Hong Kong
    MS-Off Ver
    Office 365
    Posts
    17

    Re: Summing up to a point

    Thanks mate, will put in effort to learn all three type! Consider this solved.

  14. #14
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: Summing up to a point

    You're welcome.



    It would be very nice if you were to just click the Add Reputation button at the foot of any of the posts of members who helped you reach a solution.

    Finally, if that takes care of your original question, please select "Thread Tools" from the menu link (just above the first post in the thread) and mark this thread as SOLVED.

+ 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. Replies: 1
    Last Post: 03-07-2020, 05:27 AM
  2. Start new animation with same departure point as arrival point in previous slide
    By isabelle.r in forum PowerPoint Formatting & General
    Replies: 1
    Last Post: 03-21-2019, 04:01 AM
  3. Replies: 6
    Last Post: 05-28-2018, 01:39 PM
  4. Maths behind rotating rectangle around start point instead of default center point
    By Stanley91 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-08-2014, 11:01 AM
  5. Replies: 2
    Last Post: 06-27-2011, 10:47 PM
  6. Summing a column from a different starting point
    By Lokii in forum Excel General
    Replies: 7
    Last Post: 08-25-2008, 03:31 PM
  7. summing a column up to a point
    By Heather in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-01-2006, 11:00 PM

Tags for this Thread

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