Search product price by latest date

hpernaf

New Member
Joined
Jul 1, 2019
Messages
27
Hi everyone!


I am new here in the forum and I looked for some solution to my problem and I did not find anything similar, so I decided to create a new post.


I have a workbook with two worksheets "STOCK" and "SALES REGISTRATION".


In Stock, I give all of my products that I buy to sell, entering the date of purchase, the product code, the description, the amount paid and the amount that will be sold. Note that the same product may change price according to the date of entry.
sales.png


In "Sales Registration" I enter all sales of my products by the date of Sale, Product code, product, amount paid and value sold.
sales.png


In this case, in columns D and E (Paid Value and Sold Value) I need to load their values according to the most current price in my stock.


That is, whenever I make a new sale, Excel should look in my inventory to see what is the latest price for that product according to my date of sale.


I even managed to do this using the INDEX and MATCH functions as the matrix functions. But since my record sales will be large, the spreadsheet turned out to be extremely heavy and slow to pull values.


My question is: Is there a way to do this without the use of dot matrix functions? I tried something like vlookup and match but I also could not.


I'm leaving the worksheet attached. If anyone can help me, I'll be very grateful.




https://drive.google.com/file/d/1sMqrL_07RSajItXG_wVYVaOOcYr2crjc/view?usp=sharing
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Index match would be no good here, nor vlookup, since i presume the most current price is at the bottom of the list. Is that correct?
 
Upvote 0
Try this formula in D3:

=LOOKUP(1,0/('STOCK '!$A$3:$A$11<=$A3)/('STOCK '!$B$3:$B$11=$B3),'STOCK '!D$3:D$11)

Copy across and down.
 
Upvote 0
something like this?

[Table="width:, class:head"]
[tr=bgcolor:#FFFFFF][td=bgcolor:#70AD47]Date[/td][td=bgcolor:#70AD47]Product Code[/td][td=bgcolor:#70AD47]Product[/td][td=bgcolor:#70AD47]Amount paid[/td][td=bgcolor:#70AD47]Sold value[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E2EFDA]
30/06/2019​
[/td][td=bgcolor:#E2EFDA]111[/td][td=bgcolor:#E2EFDA]Mouse[/td][td=bgcolor:#E2EFDA]
11​
[/td][td=bgcolor:#E2EFDA]
22​
[/td][/tr]

[tr=bgcolor:#FFFFFF][td]
30/06/2019​
[/td][td]222[/td][td]Keyboard[/td][td]
21​
[/td][td]
42​
[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#E2EFDA]
30/06/2019​
[/td][td=bgcolor:#E2EFDA]333[/td][td=bgcolor:#E2EFDA]RAM memory[/td][td=bgcolor:#E2EFDA]
52​
[/td][td=bgcolor:#E2EFDA]
104​
[/td][/tr]
[/table]


or post expected result
 
Last edited:
Upvote 0
SALES REGISRATION

D3=IF($A3<>"",IF('SALES REGISTRATION'!$A3=MAX(IF('STOCK '!$B$3:$B$11='SALES REGISTRATION'!$B3,IF('STOCK '!$C$3:$C$11='SALES REGISTRATION'!$C3,'STOCK '!$A$3:$A$11))),SUMIFS('STOCK '!D$3:D$11,'STOCK '!$A$3:$A$11,'SALES REGISTRATION'!$A3,'STOCK '!$B$3:$B$11,'SALES REGISTRATION'!$B3,'STOCK '!$C$3:$C$11,'SALES REGISTRATION'!$C3),""),"")

Control + shift +enter

copy across and down
 
Upvote 0
SALES REGISRATION

D3=IF($A3<>"",IF('SALES REGISTRATION'!$A3=MAX(IF('STOCK '!$B$3:$B$11='SALES REGISTRATION'!$B3,IF('STOCK '!$C$3:$C$11='SALES REGISTRATION'!$C3,'STOCK '!$A$3:$A$11))),SUMIFS('STOCK '!D$3:D$11,'STOCK '!$A$3:$A$11,'SALES REGISTRATION'!$A3,'STOCK '!$B$3:$B$11,'SALES REGISTRATION'!$B3,'STOCK '!$C$3:$C$11,'SALES REGISTRATION'!$C3),""),"")

Control + shift +enter

copy across and down



****** id="cke_pastebin" style="position: absolute; top: 0px; width: 1px; height: 1px; overflow: hidden; left: -1000px;">That got me.
Thanks for your help!
</body>
 
Upvote 0
To be ok for post #5 here is PowerQuery solution

Code:
[SIZE=1]// Table1
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Type = Table.TransformColumnTypes(Source,{{"Purchase date", type date}, {"Product Code", type text}, {"Product", type text}, {"Amount paid", type number}, {"Sold value", Int64.Type}}),
    Group = Table.Group(Type, {"Product Code", "Product"}, {{"Date", each List.Max([Purchase date]), type date}, {"Count", each _, type table}}),
    LastAmount = Table.AddColumn(Group, "Amount paid", each List.Last([Count][Amount paid])),
    LastSold = Table.AddColumn(LastAmount, "Sold value", each List.Last([Count][Sold value])),
    ROC = Table.SelectColumns(LastSold,{"Date", "Product Code", "Product", "Amount paid", "Sold value"})
in
    ROC[/SIZE]
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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