+ Reply to Thread
Results 1 to 6 of 6

Fast array formula for running sum of a column for consecutive identical values in another

  1. #1
    Registered User
    Join Date
    07-12-2022
    Location
    Switzerland
    MS-Off Ver
    365
    Posts
    3

    Question Fast array formula for running sum of a column for consecutive identical values in another

    I have a column (column E) with integer values, and another column (F) with arbitrary values. I want to compute, in column G, the running total of F, but limited to the segment of consecutive rows where the current value of [ICODE]F[/ICODE] is constant. The description may be easier to understand with formulas:
    Please Login or Register  to view this content.
    I don't know in advance how long the sequence will be and I would like to use an array formula to automatically adjust the length of the output, instead of repeating the formula in G2 in the G column.
    The following formula works:
    Please Login or Register  to view this content.
    but is much slower than the G2 formula above: it becomes slow when the sequence has a length in the thousands, while the G2 formula can easily handle hundreds of thousands of values.

    How can I make the array formula as fast as the non-array formula?
    (and BTW, why is the array formula so slow? All operations inside it should be very fast.)

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2403 Win 11 Home 64 Bit
    Posts
    23,810

    Re: Fast array formula for running sum of a column for consecutive identical values in ano

    crossposted: https://www.mrexcel.com/board/thread...olumn.1210428/

    Rule 03: Cross-posting Without Telling Us

    Your post does not comply with Rule 3 of our Forum RULES. Do not cross-post your question on multiple forums without telling us about your threads on other forums.

    Post a link to any other forums where you have asked the same question.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Read this to understand why we ask you to do this.

    I have added the crosspost reference for you today. Please comply with this and all our rules in the future
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    07-12-2022
    Location
    Switzerland
    MS-Off Ver
    365
    Posts
    3

    Re: Fast array formula for running sum of a column for consecutive identical values in ano

    Sorry, I wrote the cross-posting reference in the first version of the post, but as a new user I am not allowed to include links, and so I removed it.

  4. #4
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    79,365

    Re: Fast array formula for running sum of a column for consecutive identical values in ano

    Forum rule #3:

    3. Questions that are cross-posted to other web forums must contain links to those posts on those forums or a comment to tell us where else the question has been asked. (A, Z*)
    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.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  5. #5
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Fast array formula for running sum of a column for consecutive identical values in ano

    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  6. #6
    Registered User
    Join Date
    07-12-2022
    Location
    Switzerland
    MS-Off Ver
    365
    Posts
    3

    Re: Fast array formula for running sum of a column for consecutive identical values in ano

    After many efforts I finally found an array formula that is almost as fast (i.e. about 3 times slower) as the non-array version:



    Please Login or Register  to view this content.

+ 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. The spread of identical consecutive values in an array
    By Anton84 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-21-2018, 11:37 AM
  2. [SOLVED] Check for 5 consecutive identical values
    By mychael14 in forum Excel General
    Replies: 11
    Last Post: 03-25-2016, 11:45 PM
  3. [SOLVED] Numbering consecutive identical cells in a column
    By boomcie in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-06-2015, 07:54 AM
  4. Formula to find identical values in same column of data.
    By murrayglue in forum Excel General
    Replies: 2
    Last Post: 04-25-2011, 07:17 AM
  5. Flaging identical data in 3, 5 and 20 consecutive cells in a column
    By SNarfel in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-14-2007, 05:23 PM
  6. [SOLVED] Need to find two consecutive identical cells (in a column).
    By How did I get here? in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-03-2006, 03:15 PM
  7. identical macros run fast and slow
    By markwattwood in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-08-2005, 04:15 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