Vlookup between 2 tables

shophoney

Active Member
Joined
Jun 16, 2014
Messages
281
Hi,

I would like to find a way to look up what the discount was on an item within a table.

1614279214827.png

Sku 1100748, what was the price back in November 1/19

Below shows it has been marked down 3 times. the price from Aug 1/19 on was $20 (disc_amt).

How can I tell vloookup to look at the price that was in Nov 1/19. This item could have been further reduced after Nov 19, so it needs to look after / before dates.

1614279272230.png


thanks
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
My interpretation is that you want the last price equal to or before the transaction date for that SKU.
If that is correct then this should work for you.

Don't let my dates throw you, I am in Sydney Australia and our date format is dd/mm/yyyy

The MaxIfs finds the latest date that is <= the transaction date for that sku.
The SumIfs then uses that date and the sku to get the discount amount.

20210226 XLookup Approx Sort Test.xlsx
ABCDEF
1
2datesku_nodisc_amt lookup
31/11/2019110074820
4
5
6sku_nodisc_codeseq_nodisc_amtdisc_typestart_active_dt
7110074820O1/08/2019
8110074830O4/12/2018
9110074830O22/11/2018
10
Price History
Cell Formulas
RangeFormula
C3C3=SUMIFS(db_DiscHistory[disc_amt], db_DiscHistory[sku_no],$B3, db_DiscHistory[start_active_dt],MAXIFS(db_DiscHistory[start_active_dt],db_DiscHistory[sku_no],B$3,db_DiscHistory[start_active_dt],"<="&$A3))
 
Upvote 0
My interpretation is that you want the last price equal to or before the transaction date for that SKU.
If that is correct then this should work for you.

Don't let my dates throw you, I am in Sydney Australia and our date format is dd/mm/yyyy

The MaxIfs finds the latest date that is <= the transaction date for that sku.
The SumIfs then uses that date and the sku to get the discount amount.

20210226 XLookup Approx Sort Test.xlsx
ABCDEF
1
2datesku_nodisc_amt lookup
31/11/2019110074820
4
5
6sku_nodisc_codeseq_nodisc_amtdisc_typestart_active_dt
7110074820O1/08/2019
8110074830O4/12/2018
9110074830O22/11/2018
10
Price History
Cell Formulas
RangeFormula
C3C3=SUMIFS(db_DiscHistory[disc_amt], db_DiscHistory[sku_no],$B3, db_DiscHistory[start_active_dt],MAXIFS(db_DiscHistory[start_active_dt],db_DiscHistory[sku_no],B$3,db_DiscHistory[start_active_dt],"<="&$A3))

Hi Alex,

Your solution is great.

I just have one problem. I want to apply the same formula for the next column.

I need to pull the first four characters. So 30PC200107 = 30pc or $20N071818 = $20n

But the formula you provided seems to pull 0

Steven
 
Upvote 0
Hello Steven,
Sumifs works in more versions of Excel but only works if the return value is numeric.
Here is the same formula converted to an XLookup in the hope your version of Excel supports that.
I am assuming you are ok to wrap that with a Left("return_value",4)

Excel Formula:
=XLOOKUP(1,
(db_DiscHistory[sku_no]=$B3)*
(
db_DiscHistory[start_active_dt]=MAXIFS(db_DiscHistory[start_active_dt],db_DiscHistory[sku_no],B$3,db_DiscHistory[start_active_dt],"<="&$A3)),db_DiscHistory[disc_amt],"",0)

PS: its 3:30 am in the morning here (Sydney Aust) - so I hopefully I won't respond again until later today.
 
Upvote 0
Alex,

Thanks that is great. I hate to keep asking questions.

But numbers can cause confusion.

As you will see below. when the discount is % I want the highest % off. And when it's $ i want the lowest price.

Using the formula you provided picked $78 on Nov 1/19 date. But price should have been $40 on 9/12/19 (September)

1614364163954.png

I hope my PS didn't put you off, how did you go with the Xlookup ?
Thanks for all your help Alex. I am currently testing the X look up function in XL but there is a lot of data for me to review. Thanks
 
Upvote 0
Assuming your picture starts at Column A, send me a copy of the formula you are using and a picture or XL2BB shot of the sheet with the lookup in it. If a picture you need to include the Row & Column information.
Based on SKU 1134082 and the Date being Nov 1/19, the formula I sent should have picked up the 40.
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,717
Members
448,985
Latest member
chocbudda

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top