[Solved] VLOOKUP finds incorrect match

Discuss the spreadsheet application
Locked
adventurehouse
Posts: 20
Joined: Thu Jun 23, 2016 4:42 pm

[Solved] VLOOKUP finds incorrect match

Post by adventurehouse »

I hope someone can help me, as this has me stumped. I have an antique booth with my wife, and I created a spreadsheet to keep track of sales and inventory. I have a sheet marked as Inventory, and another on another tab marked Sales 2024. My wife is a former banker, but she knows nothing about computers and spreadsheets. So I tried to make things easier, and I've had some errors that I can't figure out.

My Inventory sheet has several columns including SKU, Vendor, Brand, Description, Qty, Retail and Cost.
My Sales Sheet has similar structure with a few additional fields. We enter the SKU number of a sale and VLOOKUP populates the Vendor, Description, Retail and Cost fields. The problem is that VLOOKUP finds the wrong SKU at what appears to be random times in the Inventory and populates the wrong information into the Sales sheet.

For the life of me, I can't figure out why.

If you look at the sample spreadsheet, and go down to the bottom of the Sales 2024, you'll find a SKU # of 45219, 45216, 45217 and the description should be John Carter Graphic Novel, instead it shows Vintage Gold Three Flower Earring Tree, which is SKU #2840.

Could it be that I mix four digit SKU's and five and six digit SKU's? I'm completely perplexed.
Attachments
antique_booth_small_sample.ods
(107.03 KiB) Downloaded 43 times
Last edited by MrProgrammer on Mon Aug 19, 2024 4:39 pm, edited 3 times in total.
Reason: Edited topic's subject
OpenOffice 4.1.2 on Mac Os X
User avatar
MrProgrammer
Moderator
Posts: 5430
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

Re: VLOOKUP Errors

Post by MrProgrammer »

adventurehouse wrote: Mon Aug 19, 2024 3:21 pm The problem is that VLOOKUP finds the wrong SKU at what appears to be random times in the Inventory and populates the wrong information into the Sales sheet.
[Tutorial] VLOOKUP questions and answers, Q11/A11

If this solved your problem please go to your first post use the Edit button and add [Solved] to the start of the Subject field. Select the green checkmark icon at the same time.
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.7.8, iMac Intel.   The locale for any menus or Calc formulas in my posts is English (USA).
adventurehouse
Posts: 20
Joined: Thu Jun 23, 2016 4:42 pm

Re: VLOOKUP Errors

Post by adventurehouse »

It's because I didn't give the last parameter a 0. Thanks.
OpenOffice 4.1.2 on Mac Os X
User avatar
DiGro
Posts: 224
Joined: Mon Oct 08, 2007 1:31 am
Location: Hoorn NH, The Netherlands

Re: Solved VLOOKUP Errors

Post by DiGro »

Probably caused by the not-sorted SKU's in column A of the sheet Inventory.
The five-digits numbers seem not sorted, whereas the four-digits are.

If you sort the data, based on column A and add ";1" at the end of the expressions in column D, you should be allright.

Not sorting causes to find non-exact matches, whereas in sorted columns only exact matches are found.

Make sure you always use sorted SKU's :bravo:
antique_booth_small_sample_sorted.ods
(111.78 KiB) Downloaded 45 times
EDITED: sorry, was busy typing. Saw you already found it
____________
DiGro

AOO 4.1.16 (Dutch) on Windows 11 64-bit. Scanned with Ziggo Safe Online (F-Secure)
adventurehouse
Posts: 20
Joined: Thu Jun 23, 2016 4:42 pm

Re: [Solved] VLOOKUP finds incorrect match

Post by adventurehouse »

This indeed is correct. I made a change so the VLOOKUP is non-sorted, as my wife adds new SKU's all the time, without resorting the spreadsheet.

Thanks for the help.
OpenOffice 4.1.2 on Mac Os X
Locked