+ Reply to Thread
Results 1 to 11 of 11

XLOOKUP problems with Duplicates

  1. #1
    Registered User
    Join Date
    01-03-2023
    Location
    Alabama, USA
    MS-Off Ver
    latest
    Posts
    4

    XLOOKUP problems with Duplicates

    I need to match the gallons from Sheet 1 to the correct amount on Sheet 2 in the attached spreadsheet. XLOOKUP works until it hits a duplicate amount, then it gives the first gallon data that matches rather than the correct one. Sheet 2 contains many more amount cells than Sheet 1 so many of them will not have corresponding gallon data. What is a better way to do this?
    Attached Files Attached Files
    Last edited by jet0005; 01-03-2023 at 10:24 PM.

  2. #2
    Forum Expert
    Join Date
    02-10-2019
    Location
    Georgia, USA
    MS-Off Ver
    Office 365
    Posts
    3,228

    Re: XLOOKUP problems with Duplicates

    I don't know how you're getting the Amount #'s when the Gallons aren't found, but otherwise, this seems to work:

    On Sheet 1, Cell B3 and copy down:

    =INDEX(FILTER(Sheet2!$A$2:$A$143,Sheet2!$B$2:$B$143=Sheet1!A3,""),COUNTIFS($A$3:A3,A3))

  3. #3
    Forum Expert wk9128's Avatar
    Join Date
    08-15-2020
    Location
    China Shanghai
    MS-Off Ver
    365 V2503 and WPS V2024(12.1.0.18543)
    Posts
    4,000

    Re: XLOOKUP problems with Duplicates

    Could worksheet or tab name "Sheet2" be placed in B2:B143, the most expected result?

  4. #4
    Registered User
    Join Date
    01-03-2023
    Location
    Alabama, USA
    MS-Off Ver
    latest
    Posts
    4

    Re: XLOOKUP problems with Duplicates

    I should clarify: Sheet 1 is my raw data. I need the formula in the GAL column of Sheet two. Hope that helps.

  5. #5
    Forum Expert wk9128's Avatar
    Join Date
    08-15-2020
    Location
    China Shanghai
    MS-Off Ver
    365 V2503 and WPS V2024(12.1.0.18543)
    Posts
    4,000

    Re: XLOOKUP problems with Duplicates

    worksheet or tab name : Sheet2

    Cell B2 formula , Drag down

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  6. #6
    Forum Expert
    Join Date
    02-10-2019
    Location
    Georgia, USA
    MS-Off Ver
    Office 365
    Posts
    3,228

    Re: XLOOKUP problems with Duplicates

    In B2, copy down, then how about this?

    =IFERROR(INDEX(FILTER(Sheet1!$A$3:$A$61,Sheet1!$B$3:$B$61=Sheet2!A2),COUNTIFS($A$2:A2,A2)),0)

  7. #7
    Registered User
    Join Date
    01-03-2023
    Location
    Alabama, USA
    MS-Off Ver
    latest
    Posts
    4

    Re: XLOOKUP problems with Duplicates

    These both appear to have worked. Thank you for the help! Out of curiosity, what was your thought process behind this, and using the formulas you did, rather than XLOOKUP?

  8. #8
    Forum Expert
    Join Date
    02-10-2019
    Location
    Georgia, USA
    MS-Off Ver
    Office 365
    Posts
    3,228

    Re: XLOOKUP problems with Duplicates

    Because you didn't want the first match. If you wanted the first match, the XLOOKUP would be the way to go. But because you wanted to skip the first match if it was a repeat number, we had to do it the way we did.

  9. #9
    Registered User
    Join Date
    01-03-2023
    Location
    Alabama, USA
    MS-Off Ver
    latest
    Posts
    4

    Re: XLOOKUP problems with Duplicates

    I have an add-on question. In my real spreadsheet there are several instances of the value 1.00 in the Gallon column from Sheet 1. I would like to show nothing or "" whenever there is a 1.00 value in the Gallon raw data. Is there a way we could add this logic into the formulas above?

  10. #10
    Forum Expert
    Join Date
    02-10-2019
    Location
    Georgia, USA
    MS-Off Ver
    Office 365
    Posts
    3,228

    Re: XLOOKUP problems with Duplicates

    Well, quickly I would just do this:

    =LET(a,IFERROR(INDEX(FILTER(Sheet1!$A$3:$A$61,Sheet1!$B$3:$B$61=Sheet2!A4),COUNTIFS($A$2:A4,A4)),0),IF(a=1,"",a))

  11. #11
    Forum Expert wk9128's Avatar
    Join Date
    08-15-2020
    Location
    China Shanghai
    MS-Off Ver
    365 V2503 and WPS V2024(12.1.0.18543)
    Posts
    4,000

    Re: XLOOKUP problems with Duplicates

    @jet0005 You're Welcome. Glad to help . Thank You for the feedback and rep.

+ 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 and Duplicates
    By SweetBaboo in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 10-20-2022, 09:02 AM
  2. [SOLVED] XLOOKUP gives N/A
    By Hexdax in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 08-23-2022, 04:06 AM
  3. [SOLVED] Using XLOOKUP to calculate without duplicates
    By MitchMitchell in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-08-2022, 12:13 AM
  4. Problems removing duplicates from a LONG list based on conditions
    By metalpoker in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-10-2011, 06:36 AM
  5. Replies: 3
    Last Post: 03-09-2011, 07:00 PM
  6. Remove Duplicates and collapsing problems
    By -Rev- in forum Excel General
    Replies: 3
    Last Post: 08-24-2010, 12:09 PM
  7. Worksheet having problems removing duplicates,
    By donnydorko in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-30-2009, 10:55 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