+ Reply to Thread
Results 1 to 16 of 16

Dynamic array horizontal lookup across 2D range

  1. #1
    Forum Contributor
    Join Date
    08-20-2011
    Location
    Oslo
    MS-Off Ver
    MS 365
    Posts
    245

    Dynamic array horizontal lookup across 2D range

    Hi,

    I have attached an example workbook where I have six separated columns with date/time values. In a seventh column, I am have a XLOOKUP formula that returns the heading of the column that contains the maximum value for that row.

    I would like to have a formula that does the same, but which doesn't require to be copied down through the column; in other words a dynamic array version.

    Does anybody know how to do that?

    Regards,
    Marbleking
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365 for MAC
    Posts
    3,105

    Re: Dynamic array horizontal lookup across 2D range

    Hi,


    Try this:

    =IFERROR(INDEX($A$1:$K$1,,MMULT(--(BYROW(A2:K12,LAMBDA(A,MAX(A)))=A2:K12)*(COLUMN(A2:K12)),SEQUENCE(COLUMNS(A1:K1),,,0))),"")
    Attached Files Attached Files

  3. #3
    Forum Contributor
    Join Date
    08-20-2011
    Location
    Oslo
    MS-Off Ver
    MS 365
    Posts
    245

    Re: Dynamic array horizontal lookup across 2D range

    Thanks a lot, belinda200!

    I don't have BYROW and LAMBDA in my Office 365 yet, but I guess it won't be too long.

    Regards,
    Marbleking

  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
    80,460

    Re: Dynamic array horizontal lookup across 2D range

    LAMBDA is in the 2020 release and BYROW in the 2021. If you sign up to the Insider Beta Channel, you can get your hands on them now and jump the queue.

    https://learn.microsoft.com/en-us/of...5-apps-by-date
    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 Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,410

    Re: Dynamic array horizontal lookup across 2D range

    Or try
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    BYROW and LAMBDA should be available to all EXCEL 365 users
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365 for MAC
    Posts
    3,105

    Re: Dynamic array horizontal lookup across 2D range

    Marbleking, you're welcome, hope you found how to activate these functions as they are supposed to be available if you are using MS365......

    @ HansDouwe,

    Can you please explain how the SORTBY works here?
    when I try to apply it as a separate segment it returns an error.
    So how does it work for you with the BYROW?

    Thanks!

    =INDEX(SORTBY(A1:K1,A2:K12,-1),1)

  7. #7
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,410

    Re: Dynamic array horizontal lookup across 2D range

    @Belinda,

    The formula I opted is =BYROW(A2:K12,LAMBDA(r,INDEX(SORTBY(A1:K1,r,-1),1)))
    If you ommit BYROW you should als ommit the LAMBDA and the first paramter of the LAMBDA.
    And where that parameter is used in the rest of the function, you then have to be replaced by the first row of A12:K12 and then copy it down for all rows.
    You also have to place the $ characters in the formula in such a way that only the row changes when you copy it down. In red is the replaced parameter r

    In that case you get for the first row this function: =INDEX(SORTBY(A$1:K$1,A2:K2,-1),1). For the second row this function =INDEX(SORTBY(A$1:K$1,A3:K3,-1),1) and so on.

    This function for the first row =INDEX(SORTBY(A$1:K$1,A2:K2,-1),1) sorts A2:K2 in a decending way and returns the corresponding values A1:K1.
    Finally INDEX(<formula>,1) selects only the first value.
    Last edited by HansDouwe; 11-09-2022 at 02:23 PM.

  8. #8
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365 for MAC
    Posts
    3,105

    Re: Dynamic array horizontal lookup across 2D range

    Got it! thank you so much for the explanation HansDouwe, I understand that now.

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

    Re: Dynamic array horizontal lookup across 2D range

    But does it work for Row 8??

    An alternative:
    =IFERROR(INDEX($A$1:$K$1,MATCH(MAX(A2:K2),A2:K2,0)),"")
    Attached Files Attached Files
    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.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  10. #10
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365 for MAC
    Posts
    3,105

    Re: Dynamic array horizontal lookup across 2D range

    Quote Originally Posted by Glenn Kennedy View Post
    But does it work for Row 8??

    An alternative:
    =IFERROR(INDEX($A$1:$K$1,MATCH(MAX(A2:K2),A2:K2,0)),"")
    i think the OP wanted a dynamic array which "doesn't require to be copied down through the column"

  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 2403
    Posts
    43,986

    Re: Dynamic array horizontal lookup across 2D range

    Ah yes... I see that now. Yours seems fine. I was querying Hans, who (unusually) seems to have got it wrong. Normally he gets it absolutely correct!!

  12. #12
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365 for MAC
    Posts
    3,105

    Re: Dynamic array horizontal lookup across 2D range

    Here is an amendment for row 8:
    =BYROW(A2:K12,LAMBDA(r,IF(SUM(r)=0,"",INDEX(SORTBY(A1:K1,r,-1),1))))

  13. #13
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365 for MAC
    Posts
    3,105

    Re: Dynamic array horizontal lookup across 2D range

    Quote Originally Posted by Glenn Kennedy View Post
    Ah yes... I see that now. Yours seems fine. I was querying Hans, who (unusually) seems to have got it wrong. Normally he gets it absolutely correct!!
    I cant complain, I learnt from him something new today : ) Thanks again Hans.

  14. #14
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,410

    Re: Dynamic array horizontal lookup across 2D range

    But does it (formula post #5) work for Row 8??
    No it does not.

    But the formula of Belinda in post #12 or the formula below does:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by HansDouwe; 11-09-2022 at 04:19 PM.

  15. #15
    Forum Contributor
    Join Date
    08-20-2011
    Location
    Oslo
    MS-Off Ver
    MS 365
    Posts
    245

    Re: Dynamic array horizontal lookup across 2D range

    Happy to see the lively discussions around this challenge. And thanks for the contributions.

    Regards,
    Marbleking

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

    Re: Dynamic array horizontal lookup across 2D range

    And, for my own education... another option:

    =BYROW(A2:K12,LAMBDA(x,XLOOKUP(MAX(x),x,A1:K1,"")))

+ 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] COUNT Dynamic Array based on Date to return Dynamic Array Spill Range
    By dluhut in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-06-2022, 01:14 PM
  2. [SOLVED] Lookup that returns vertical array in horizontal format
    By chanelinyavapai in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-25-2022, 10:50 AM
  3. [SOLVED] Horizontal dynamic range not working
    By steam73 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 06-01-2017, 09:32 AM
  4. [SOLVED] Finding the (Dynamic) End of a Horizontal Range
    By Lemmy Kickit in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-12-2016, 06:52 PM
  5. [SOLVED] lookup if my lookup array with my data position is vertical and horizontal
    By daboho in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-29-2015, 05:35 AM
  6. Dynamic Chart Range for Horizontal values
    By phill_howz in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-03-2014, 11:47 AM
  7. [SOLVED] Sum Array Using List of criteria and a horizontal lookup
    By Greg in forum Excel General
    Replies: 7
    Last Post: 05-21-2005, 07:06 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