Comments on: XLOOKUP function in Excel with formula examples

The tutorial introduces XLOOKUP - the new function for vertical and horizontal lookup in Excel. Left lookup, last match, Vlookup with multiple criteria and a lot more things that used to require a rocket science degree to accomplish have now become as easy as ABC. Continue reading

Comments page 3. Total comments: 162

  1. How do I get a return of multiple column headers by matching a repeated row value using Xlookup? Ex. Column headers are different shopping centers and rows are different items. I am trying to look up a specific item (row) and the return to be a list of column headers (shopping centers) that sell the item. Thank you

  2. Hi - this is the best tutorial I've come across. Thanks

    1- I have two Sheets (LISTING= with columns: Vendor Name, ID# and Hotel; & HOTEL= with 9 columns that contain the first 3 cols as: Priority Vendor1, ID# & Email ; Priority Vendor2, ID# & Email; and Priority Vendor3, ID# & Email

    2- I need to return the vendor name found on either one of the Priority Vendor1, 2 or 3 cols based on the ID# on the LISTING sheet, but I haven't been able to get results by doing a search of the ID# on (sheet1) on the 3 cols of sheet2

    Is this possible?

  3. I am comparing 2 columns. The first column has 16318 rows and the second 18526 rows. The formula =XLOOKUP(C2, B2:B18584, A2:A18584, "No match is found") works perfectly.

    My question: Is there a way to populate the formula in column "D" incrementing the C2 value without changing the range values? When I use ctl and pull the corner of the cell down to copy into subsequent cells the first cell value of the ranges also increments resulting the elimination of one cell for every copy.

    Example: =XLOOKUP(C61, B61:B18584, A61:A18584, "No match is found")
    Thanks for your insight.

      1. Alright I know this is very late but I must let you know how much I appreciate this response. It has corrected something that was plaguing me tremendously and saved so much data entry time. Thank you for the assist.

  4. Is XLookup able to return the first result that has a negative number?

  5. Is there a way to use xlookup (or maybe it would be something else) to return one value from two. To explain I have a table in document 1 that has included in it first names (column c) and last names (column B) and I want it to find and input the ID number (column A) from document 2. Document 2 has all of the above information and other information that I don't need, all in separate columns. So I need it to get a match to both first and last name for it to get the ID number. Unfortunately, the way it is set up, I cannot do the inverse and input the ID numbers and search for the first and last names. Is there a way to do this? Another option is I can have it in document 1 as LastName, First Name in column B and ID number in column A, but document 2 would still have the last name and first name separate.

    Thanks in advance!!

    1. Hello!
      You can search by two criteria with INDEX+MATCH or XLOOKUP. See formula examples here.
      To input the ID numbers and search for the first and last names, you can use the paragraph in this article above: XLOOKUP to return multiple columns or rows.
      I hope I answered your question. If something is still unclear, please feel free to ask.

  6. I'm trying build out an excel file using two sheets. I'm trying to use the ID# from column A sheet one to find said ID# from sheet two. Then I'd like it to search for the row title from sheet 1 on sheet 2 to pull sheets 2s value into sheet 1. Is this possible?

  7. How would you use the function of xlookup in excel? And what was the function names before as?

    Someone can answer this please. Thanks in advance ?

  8. Hi! I'm trying to use XLOOKUP for the following situation but I don't know how to do so the number of cals finds the right pricing tier.
    I have 1 table with 14 columns: a) a CONCAT formula to add in 1column the centre, market & channel info (BsAsARGcall) b) different pricing tiers, under 4000 calls there's a price for each centre, market & channel and the same for every tier: over 8000, over 10000 calls, etc there's a different price according to amount of contacts
    In another table I have a column with another CONCAT formula same info as above (centre, market,channel) and then the column with amount of calls per centre, market, channel.
    What I need to do is for the XLOOKUP to find the right price by searching the right tier column (under 4000, over 8000, etc) and bring the right price according to the amount of calls. Any help? Hope I was able to explain myself clearly :-)

  9. Hi,
    I need to retrieve data under certain conditions from one sheet to another, and here is the formula I am using: =XLOOKUP((IF(OR('by sample'!$H4="cheek, right",'by sample'!$H4="cheek, left"),'by sample'!$H4,"")),'by sample'!$H4:$H1000,'by sample'!B4:B1000,,0).
    It works well, but when the results is N/A I would like excel to find the next xlookup value.
    I am trying to write an IFNA of the sort: IFNA(XLOOKUP(...), find next xlookup value) to avoid removing the cells manually/with find and select tool, but without success...
    How could I proceed?

  10. HI,
    I am trying to copy down the XLOOKUP function to use it for an entire column but it is changing the search array.
    EXP.
    XLOOKUP(B1, C2:C6, D3:D7) then when I copy down I want XLOOKUP(B2, C2:C6, D3:D7) but I get XLOOKUP(B2, C3:C7, D4:D8). It shifts all by 1 cell instead of just the search value.

    How do I get it to automatically shift the search but not the other 2 array?

    Thanks

  11. Hello - has this replaced the use of Transpose and Filter? I used to use this formula to look up an array that had multiple instances and returns in one column: "=TRANSPOSE(FILTER(C2:C6, B9=B2:B6))". Where C2:C6 had the expected outputs (more than one output but only in one column) B9 is the criteria to lookup and B2;B6 is the array to look for it in.
    When I use it now I need a NAME error which seems to indicate its no longer a recognized formula name.
    I cant find the equivalent in the xlookup formula i.e. where the multiple responses are all in the same column.

  12. Very informative, thank you. I was particularly interested in XLOOKUP with multiple criteria. You use:

    XLOOKUP(1, (criteria_range1=criteria1) * (criteria_range2=criteria2) , return_array)

    I had not seen this before, and previously I had used concatenation, for example:

    XLOOKUP(criteria1 & criteria2, criteria_range1 & criteria_range2, return_array)

    But this can be very slow if you are referencing whole columns. Do you know if your approach is faster? I suspect it would be.

    1. Hello!
      I do not recommend using the entire column as criteria_range (for example, A:A). This will slow down the calculations significantly. Use the range where the data is actually located (for example, A2:A100).

      1. Thanks Alexander. Yes I appreciate that using specific ranges is faster than entire columns. In some models though I find column references are preferable, as the formulas are easier to read and you don't have to worry about users adding new data to rows outside the range.

        I guess my question is, *for a given range of data*, whether there is a significant difference in speed between the two XLOOKUP approaches above. I might have a play around to see.

  13. Hi -
    this may not be an xlookup question.

    I have one sheet with a list of protein names in column A, and on another sheet, a list of biological pathways (column A), with the corresponding proteins that are found in that pathway listed across columns B-Z in that row. Every pathway has column B filled (at least 1 protein per pathway), but after that has a variable number of entries depending on how many proteins are associated with that pathway (from 1 up to 25, with any remaining cells blank). All proteins on sheet 2 are contained in the list on sheet 1, and vice versa. There should be no "not founds".

    I want to enter a formula in sheet 1 by which sheet 2 will be searched for each protein name and for each, return which pathways it is associated with, returning those pathway names into sheet 1, column B (and C and D and so on until all relevant pathways are listed).

    a small made up example, separate column entries separated by pipes
    sheet 1 (single letter protein names)
    A
    B
    C
    D

    sheet 2 (pathway name|protein|protein|protein)
    Notch|A|B|C|D
    WNT|A|B|D
    EGFR|C|D|A
    RAS|D

    desired results, sheet 1:
    A|Notch|WNT|EGFR
    B|Notch|WNT
    C|Notch|EGFR
    D|Notch|WNT|EGFR|RAS

    Any help appreciated.
    thanks

    1. Hello!
      To get data by condition, you can use the FILTER function.
      I believe the following formula will help you solve your task:

      =TRANSPOSE(INDEX(FILTER(Sheet2!$A$1:$E$4,(Sheet2!$B$1:$B$4=Sheet1!A1)+(Sheet2!$C$1:$C$4=Sheet1!A1)+(Sheet2!$D$1:$D$4=Sheet1!A1)+(Sheet2!$E$1:$E$4=Sheet1!A1)),,1))

  14. Do you know what is the correct syntax if I would like to implement the following query inside of a VBA code? =XLOOKUP(1, (B2:B10=G1) * (A2:A10=G2) * (C2:C10=G3), D2:D10)
    I would like to implement the following, which works well in pasted in a cell:
    =XLOOKUP(1;(Elisa!$J$2:$J$2015=BH$2)*(Elisa!$B$2:$B$2015=$AY7);Elisa!$E$2:$E$2015;" ")
    What I have tried:
    Worksheets("Adatbázis").Cells(H, I).Value = WorksheetFunction.XLookup(1, (Worksheets("Elisa").Range("J2:J2015") = Cells(2, I)) * (Worksheets("Elisa").Range("B2:B2015") = Cells(H, 51)), Worksheets("Elisa").Range("E2:E2015"), " ")
    This always ends with a Tyme mismatch message around this part: Worksheets("Elisa").Range("J2:J2015") = Cells(2, I). I have tried it several ways but no luck so far...

  15. I really like the xlookup function but I am struggling with a situation I am unable to resolve.

    I want to use the xlookup to find a transaction in a check register and put that transaction in a budget report. I am able to get xlookup to find a single line item for a budget category but when a category has multiple entries xlookup is only returning the first line item of that category. What I am after is not only to find the first transaction of a particular category but to find all of them and add(sum) them all together into one cell. ex: find all amounts paid for groceries then sum them all together.

    I am using the date & category as a reference to find the amount paid in each category. Here is the formula I am using it only finds the first transaction. How do I need to change it to find all transactions and sum them all together in one cell?

    =IFERROR(XLOOKUP($J$4&F15,'Arvest Savings'!$C:$C&'Arvest Savings'!$E:$E,'Arvest Savings'!$H:$H,,0),"")

    The above formula is going into the budget form under the actual column then once the entry is made in the check register it automatically populates into the budget form for the appropriate month,

    It works great for a single transaction where I need assistance is with finding multiple transactions and getting them summed all together.

  16. how does xlookup work for multiple tables - two similar sets of data, one for onshore and one for offshore. I have Line of work (Java, testing etc), Designation (Manager, Team lead, etc), rate for line of work vs designation. This calculation is straight forward if its only for offshore or onshore. Now If i have to get both in one formula should I use IFERROR ?

  17. I'm struggling with XLOOKUP and dates with multiple criteria. Please help!
    I'm trying to return a Lab value for a particular ID collected on a date that is closest to, but before or equal to, the Clinic Date.
    For example for ID: A251527 on Clinic Date 17/09/2008 (in cells E2 and F2 respectively).
    The answer should be 130 on 12/08/2008 but XLOOKUP using multiple criteria seems to return the Lab value on the first date for this ID (124).

    =XLOOKUP(1, ($A$2:$A$17="ID")*(LARGE($B$2:$B$17,COUNTIF($B$2:$B$17,">"&$F$2)+1)<=F2), $C$2:$C$17)

    The data is unsorted and is large ~110,000 rows.

    Clean ID Date Collected Lab value ID Clinic date
    A251300 17/09/2008 118 A251527 17/09/2008
    A251300 16/09/2008 129
    A251527 13/06/2008 124
    A251527 16/06/2008 115
    A251527 18/06/2008 114
    A251527 23/06/2008 113
    A251527 24/06/2008 108
    A251527 24/06/2008 113
    A251527 12/08/2008 130
    A251527 03/11/2008 133
    A251527 19/02/2009 120
    A251527 20/02/2009 112
    A251527 21/02/2009 122
    A251527 22/02/2009 138
    A252601 19/08/2008 136
    A252601 10/02/2009 117

    1. Hello!
      You cannot apply XLOOKUP approximate search on unsorted data.
      If I got you right, the formula below will help you with your task:

      =INDEX(C2:C17,MATCH(MAX(IFERROR((B2:B17-E2) / ((A2:A17=D2)*((B2:B17-E2)<0)),-100000)), (A2:A17=D2)*(B2:B17-E2),0))

      In Excel 365:

      =VLOOKUP(E2,SORT(FILTER(B2:C17,(B2:B17 < E2)*(A2:A17=D2)),2,1),2,1)

      I hope my advice will help you solve your task.

      1. Thanks for replying.
        Your VLOOKUP formula for Excel 365 seems to be missing some arguments at the end? Can you complete please?

  18. hi
    thank you for the post, very useful
    how can I set the Xlookup function to get the first, second, and third result on arranged set when working with multiple data in a table

      1. thank you for your prompt answer
        greetings!

  19. Hi,
    i'm trying to find out Balance Work = Scope of work - Work Done, but result always wrong.
    Please help, how to i get final result with XLOOKUP or any other function.
    Below given data is Length (m) (From-To).

    Scope of work - Work Done = Balance Work
    From To From To
    62000 66000 68000 68480
    67200 71080 68680 69300
    72000 73400 73000 73180
    73650 75500 76300 76600
    76300 76600
    77400 78080
    78300 79100
    79300 79600

    1. Hi!
      I don't really understand what you want to calculate. Why are 4 columns used? Describe in more detail. Specify the expected result.

      1. This data is related to Highway construction. in which digit shows location of highway. Terms used means:
        1. Scope of work = Construction work to be execute at that locations. (A)
        2. Work Done = Construction work has been done. (B)
        3. Balance Work = Remaining work, which is to be execute within scope of work. (C=A-B) (Result)
        4. From = Starting Point of work (62+000)
        5. To = Ending Point of work (66+000)
        (From) 62+000 - (To) 66+000 = 4000 m (Length)
        Example:

        Scope of work (A) Work Done (B) Balance Work (A-B) (Result)
        From To Length From To Length From To Length
        62+000 66+000 4000 62+000 66+000 4000 68+085 69+630 1545
        67+200 71+080 3880 67+200 68+085 885 70+015 70+065 050
        72+000 73+400 1400 69+630 70+015 385 72+000 72+100 100
        - 70+065 71+080 1015 73+175 73+310 135
        - 72+100 73+175 1075
        - 73+310 73+400 090
        This is highway measurement that's why i used 4 columns.
        I have Scope & Work Done Data and i would like to calculate Balance Work.
        I hope this will helpful to understand.
        Please Help !

        1. Hello!
          To find the difference between numbers as text 73+175 and 72+100,
          try the formula

          =--SUBSTITUTE(B1,"+","")-SUBSTITUTE(A1,"+","")

          Hope this is what you need.

          1. HI,
            =--SUBSTITUTE(B1,"+","")-SUBSTITUTE(A1,"+","")
            Formula suggested by you not solving my problem. May be i am not Letting you know what i want.
            Thank you for help !

  20. Hi.
    I have a strange issue with XLookup and structured referencing, and I cannot for the life of me work out what I’m doing wrong.
    =XLookup(A2,B:B,G:G) works, but =Xlookup(A2,Table1[ColumnB],Table1[ColumnG]) doesn’t - I get a #VALUE ERROR. Column G contains numbers. There are no spaces or other things that usually cause value errors.
    I don’t think the problem is with my syntax. The table is named Table1, and the two columns are named as above. I have used xlookup in the same format referencing other tables in the worksheet with no issues.
    Any help appreciated.

    1. Hello!
      The formula works for me. I was unable to get this error. Check the column names in your table. Column sizes must be the same.

      1. Thanks Alexander. It seems my problem was using a mixture of structured table references and named ranges in the Xlookup formula. This seems not to be allowed.

  21. Hi everyone,
    I need to perform XLOOKUP such that the criteria is Difference/Subtraction between two cells of column X and column Y. Suppose Quarter 1,2 as columns and i need to check rows where element/value of Quarter2 - element/value of Quarter1 = 25.

    In other words rows in which the difference/subtraction of Column X and Column Y is exactly equal to 25

    1. Hello!
      Please try the following formula:

      =XLOOKUP(1,--(A2:A10-B2:B10=25),A2:B10)

      This formula only returns the first value found. To get all values that meet the criteria, use the FILTER function:

      =FILTER(A2:B10,A2:A10-B2:B10=25)

      Hope this is what you need.

  22. I need to find and list all possible matches for a 'PART NAME" within a column containing FULL NAMES. Example:
    1. JOHN TERRY
    2. ADAM JOHN
    3. ADAM TERRY
    4. CRUISE JOHN
    5. JONATHAN JOHN

    I need to do an XLOOKUP to list all matching Rows containing "JOHN"

    1. Hello!
      XLOOKUP can only return one match, not a list of values. If you need to return a list of values that contain "JOHN", use this tutorial: How to VLOOKUP multiple values in Excel.

      =IFERROR(INDEX($A$1:$A$10, SMALL(IF(ISNUMBER(SEARCH($B$1,$A$1:$A$10,1)), ROW($A$1:$A$10)-1,""), ROW()-1)),"")

      This array formula is on line 2. Copy it down the column.
      I hope I answered your question. If you have any other questions, please don’t hesitate to ask.

  23. Please help how to retrieve the values using vba.

    Excel Sheet Name: Source.xlsx (Column: G -> Code)
    Excel Sheet Name: Mappings.xlsx (Column: A -> Node; Column: B -> Code)

    Example:
    In Mappings.xlsx sheet:
    When I filter by Code = 001 in Column B, there are 3 rows shown as a result with Column: A values as "001", "00100100", "00100")

    So basically one Code has multiple Nodes. I want to retrieve all the Nodes for a specific Code in vba.

    I tried with Xlookup, but its retrieving only one value for me and not all the 3 values.

  24. Thanks for your info on XLOOKUP, it was very helpful. Correct my thinking here in case it's wrong, but the XLOOKUP multiple criteria is used to construct an array (column or row) of data but can't return a multi-dimensional array (area) to be searched. Originally I was trying figure out how to use multiple criteria to filter results from a long data table during the XLOOKUP function and wasn't getting anywhere when I realized that I needed to filter the results before I performed the Xlookup. Using the concept of array-based inputs for XLOOKUP, I came up with this ...

    =XLOOKUP(0,INDEX(FILTER(A:T,A:A=D3),0,20),INDEX(FILTER(A:T,A:A=D3),0,17))

    D3 is the value I want to filter by
    A:A is the column I want to filter
    A:T are the columns I want FILTER to return to INDEX
    0 is the value I want to search for
    T (20) is the column I want to search
    Q (17) is the column I want to return data from

    This allows a custom filter to be applied to the data without modifying the original at all and returns it to the function instead of placing it in a temporary or new cell location. The FILTER functions can also have SORT applied to them before the INDEX for the bitwise searches that require it. Just make sure that what is fed to each INDEX part of the function are identical. I'm posting this here as a search for XLOOKUP combined with FILTER like this doesn't come up in any searches.

  25. Is not working if lookup array & return array from other sheet. Can you help please

  26. HI, I have a dataset with staff completing their inspections on specific dates for certain street addresses.
    Ex.
    Header rows:
    1)Area
    2) Segment
    3)Boundaries
    4)Approx. Blocks
    5)# Inspectors
    6) Bureau
    7)Team Lead
    8)Completed 12/7
    9)Completed 12/8
    10)Completed 12/9
    11)Completed 12/10
    12)Completed 12/11

    If I want to get the latest value from #8-#12 columns, what syntax can I use?

  27. Thanks this is great! For some reason the search in reverse order is not working.
    Using your example my sheet has (=XLOOKUP(G1,B2:B9,D2:D9, ,-1)) still gives me $25 as the result, not $45.
    All the other examples seem to work great

    1. Hi Dave,

      Thank you for pointing out this issue!

      It looks like Microsoft has changed the order of arguments in the XLOOKUP function! At the moment of writing, this function was a beta available for Office Insiders. That time, search_mode that controls the direction of search was the 5th argument. Now, it's the last (6th) argument. I will review and update all the affected examples ASAP.

      In the meantime, please use this formula to get the last occurrence:
      =XLOOKUP(G1, B2:B9, D2:D9, , ,-1)

  28. Hi Svetlana,
    Very complete but I am stuck with a more complex issue.
    I need to get a value based on 3 criteria, including one that is an approximate (i.e. lookup value would be within a range)
    My formula looks like this:
    =xlookup(Value01&Value02&Value03,Range01&Range02&Range03,ReturnRange,,-1) where value 03 is the approximate crlteria.

    The ranges are same lenghts and side by side. It should work however it gives me random return values, never consistent.

    Please help.

  29. I have multiple Xlookup's running in my workbook, but I'm having issues with a particular one. I have a column with pay type data (regular time, overtime) and another column where the job name is listed. I am attempting to use xlookup to determine which pay type AND if the job name is one of 3 possibilities (referencing a range of cells for that data) have it return a job type number listed in another range of cells. My current formula is =XLOOKUP($E2,AC2:AC5&($T1,AE2:AE5),AD2:AD5,E2)which returns "regular time" as the answer (which I only want it to do if it won't be replacing the data with information from the proper range). I have to be missing part of the query, but I'm not sure where.

    1. Hello!
      I’m sorry but your task is not entirely clear to me. Could you please describe it in more detail?
      What do you want to determine using this formula? Pay type? Job type? What is written in cell E2? What is written in cell T1? You are using 3 ranges of AC2: AC5 AE2: AE5 AD2: AD5. What is written in them? Without this, I cannot understand the logic of your formula

  30. Is it possible to utilize an XLOOKUP in conjunction with a range? I'd like to return a value based on a range that varies depending on the lookup criteria.

    Example. Criteria one is a customer name, Criteria two is their sales, Result/Return is a order frequency. There is 5 possible return values of what the order frequency should be based on the range of sales and the customer name. There are different ranges based on customer names.

    1. Hello Robert!
      Read carefully the section above "XLOOKUP with multiple criteria" You did not explain what you mean by "order frequency".
      I’m sorry but your task is not entirely clear to me. For me to be able to help you better, please describe your task in more detail. Please specify what you were trying to find, what formula you used and what problem or error occurred. Give an example of the source data and the expected result.
      It’ll help me understand it better and find a solution for you. Thank you.

  31. I couldn't find xlookup in excel 2019

    1. Update: the XLOOKUP function is now available in the Monthly channel of Office 365 subscriptions. Starting in July 2020, it is planned to be included in the Semi-Annual channel.

    2. Hi Hamada,

      Currently XLOOKUP is only available to users of the Office 365 Insiders channel.

  32. Hi
    I am trying to work out this formula =IF(A2>0,"Non Compliance","Compliance")but i want to exclude blank cells. How do i do that?

    thanks
    Stephane

    1. Hi Stephane,
      You can nest another IF function that checks for blanks, like this:
      =IF(A2="","", IF(A2>0,"Non Compliance","Compliance"))

Post a comment



Thank you for your comment!
When posting a question, please be very clear and concise. This will help us provide a quick and relevant solution to
your query. We cannot guarantee that we will answer every question, but we'll do our best :)