+ Reply to Thread
Results 1 to 4 of 4

MAP + XLOOKUP below a value, if not above

  1. #1
    Forum Contributor
    Join Date
    09-15-2022
    Location
    Marseille, France
    MS-Off Ver
    O365 (PC) V 2303
    Posts
    265

    MAP + XLOOKUP below a value, if not above

    Dear All :

    I use this function:

    =MAP(A5:A25,B5:B25,LAMBDA(id,qty,IF(COUNTIF(M5:M23,id),TAKE(TOCOL(XLOOKUP(qty,O5:O23/(M5:M23=id),Q5:Q23,,{-1,1}),2),1),"ALERT")))

    from an old post at https://www.excelforum.com/excel-for...ml#post5817525

    Purpose is to get the cost which corresponds to the exact qty, or the qty immediately below the requested quantity or, if it does not exist, the cost immediately above.

    It works fine, however, instead of getting only the COST (1 column: Q5:Q23), I would like to get a 2-column array with the Qty as well {Q5:Q23;O5:O23}

    This would prevent me from using the formula twice, on 2 different columns, which is quite resource consuming. Instead, I could get both results with a single XLOOKUP.

    Considering there would be an issue with the TOCOL, how can we achieve this? Thanks a lot.

    map_below_above.jpg
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    09-15-2022
    Location
    Marseille, France
    MS-Off Ver
    O365 (PC) V 2303
    Posts
    265

    Re: MAP + XLOOKUP below a value, if not above

    Or maybe, I can create a column with an unique ID, then the MAP+XLOOKUP would retrieve the unique ID number instead of the cost, then in a second step, a MATCH+INDEX or the like would return cost + qty for the selected ID (2 columns array), and this would spill for all IDs. Does this make sense?

    Thanks for your help.

    Attachment 828109
    Attached Files Attached Files

  3. #3
    Forum Contributor John Vergara's Avatar
    Join Date
    01-17-2022
    Location
    Colombia
    MS-Off Ver
    365
    Posts
    206

    Re: MAP + XLOOKUP below a value, if not above

    Hi again guillaume0314!

    Try this formula:
    PHP Code: 
    =IFERROR(INDEX((S5:S23,Q5:Q23),MAP(B5:B25,C5:C25,LAMBDA(id,qty,IF(COUNTIF(O5:O23,id),TAKE(TOCOL(XMATCH(qty,Q5:Q23/(O5:O23=id),{-1;1}),2),1),""))),,{1,2}),"ALERT"
    Blessings!

  4. #4
    Forum Contributor
    Join Date
    09-15-2022
    Location
    Marseille, France
    MS-Off Ver
    O365 (PC) V 2303
    Posts
    265

    Re: MAP + XLOOKUP below a value, if not above

    Thank you John. It works well and faster than the original formula!

+ 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. Xlookup help?
    By KArl419 in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 01-18-2023, 09:22 AM
  2. [SOLVED] How to Use XLOOKUP In VBA
    By PosseJohn in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-30-2022, 01:50 PM
  3. [SOLVED] XLOOKUP gives N/A
    By Hexdax in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 08-23-2022, 04:06 AM
  4. If this do this XLOOKUP otherwise do this XLOOKUP
    By MattKoleczko in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-21-2022, 08:14 AM
  5. [SOLVED] Xlookup in PQ
    By Excelski in forum Excel General
    Replies: 7
    Last Post: 09-09-2021, 07:15 AM
  6. Two-way Xlookup
    By Ballet4ever in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-28-2021, 10:11 PM
  7. [SOLVED] Xlookup with VBA, need some help!
    By CSimm in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-19-2021, 03:14 PM

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