+ Reply to Thread
Results 1 to 6 of 6

Formula to mimic nested "for loops" to loop through two dynamic arrays

  1. #1
    Registered User
    Join Date
    12-20-2023
    Location
    Los Angeles, CA
    MS-Off Ver
    MS Office 2021
    Posts
    2

    Formula to mimic nested "for loops" to loop through two dynamic arrays

    Hi!

    I've been trying to use Excel formulas (No VBA) to mimic the behavior of nested "for" loops. I want to create a table of calculated values, where the values are determined by filtering on the column label and row label.

    Values are pulled from a filtered dynamic array using: filter(choosecols(array, values), (choosecols(array, year) = row label) * (choosecols(array, employee) = column label))

    However, since both the row and column labels are also arrays of dynamic length, I want to use a single array-friendly function to capture both the row and column labels instead of duplicating/deleting formulas from each row/column when the label lengths change.

    I tried using map(row label array, column label array, lambda(....)), but the formulas only work when just one array is passed through this method.

    I know this can be easily accomplished through pivot tables, but I'd like to avoid them as my original file size is quite large. Would appreciate any pointers, thanks in advance! File attached has an example of my attempted formula with calc. errors, and an example of when my formula only works with one label array.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    04-14-2009
    Location
    Taiwan
    MS-Off Ver
    Excel 2016,2019,O365
    Posts
    2,005

    Re: Formula to mimic nested "for loops" to loop through two dynamic arrays

    You can use "map" function, you should use O365 version.

    If you use O365 version, you can try this.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    12-20-2023
    Location
    Los Angeles, CA
    MS-Off Ver
    MS Office 2021
    Posts
    2

    Re: Formula to mimic nested "for loops" to loop through two dynamic arrays

    Thank you!! This works great

  4. #4
    Forum Expert
    Join Date
    04-14-2009
    Location
    Taiwan
    MS-Off Ver
    Excel 2016,2019,O365
    Posts
    2,005

    Re: Formula to mimic nested "for loops" to loop through two dynamic arrays

    You are welcome.

    PS. update your profile to O365.

    -----------------------------------
    If that takes care of your original question, please click on "Thread Tools" from the menu link above and mark this thread as SOLVED.

  5. #5
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2016 & H&B2021
    Posts
    3,059

    Re: Formula to mimic nested "for loops" to loop through two dynamic arrays

    Or, you can simply use the SUMIFs Function, =SUMIFS($J$3:$J$26,$H$3:$H$26,B3#,$I$3:$I$26,C2#).

  6. #6
    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
    80,869

    Re: Formula to mimic nested "for loops" to loop through two dynamic arrays

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however it has been brought to our attention that the same query has been posted on one or more other forums and you have not told us about this. You are required to do so. Cross-posts are allowed but you must provide a link to your posts on other sites.

    Please see Forum Rule #7 about cross-posting and adjust accordingly. Read this to understand why we (and other sites like us) consider this to be important: https://excelguru.ca/a-message-to-forum-cross-posters/

    (Note: this requirement is not optional. As you are new here, I shall do it for you this time: https://www.mrexcel.com/board/thread...-once.1250788/)
    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.

+ 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] UNIQUE FILTER Formula to Mimic "Remove Duplicates"
    By ezekielfu777 in forum Excel General
    Replies: 5
    Last Post: 01-25-2023, 01:23 AM
  2. [SOLVED] Need assistance with "Pivot Table", "Slicer", and "Dynamic/Interactive Graph"
    By skydivetom in forum Excel Charting & Pivots
    Replies: 26
    Last Post: 06-27-2020, 11:03 AM
  3. [SOLVED] Need Formula mimic "Olympic Medal Award" process
    By skydivetom in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-07-2020, 07:05 AM
  4. Replies: 11
    Last Post: 12-19-2019, 04:46 PM
  5. Replies: 14
    Last Post: 02-21-2019, 03:24 PM
  6. Replies: 1
    Last Post: 03-09-2016, 12:17 PM
  7. Nested "If" formula on a Dynamic Range
    By AussieExcelUser in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-03-2007, 08:59 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