Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Find keys from another table by date and quantity

Hi,

I have 3 tables as below mocked examples:


Goods received:

partDateTimequantityunit cost
AB123452016-07-23 09:0010025.37
AB123452016-09-15 20:0015028.72
AB123452017-11-23 12:0010030.25

Stock history:

partDateTimeOn Hand Quantity
AB123452016-08-12 12:1985
AB123452017-12-27 15:00125

Sales:

PartDateTimeSale Quantity
AB123452016-08-12 12:202
AB123452017-12-27 15:001

I need to calculate the cost price of the item at the point of sale by doing the following and using first in first out logic:

* Work out how many of the good receipt lines are still relevant based on the 'on hand quantity' at point of sale.

* Work out the average cost of the parts in stock based on the quantity of each batch remaining and the unit cost of those items.

i.e.
* For the first sale there are 85 items in stock, these are fulfilled from the goods received on 2016/07/23
so the cost of sale is 25.37* 2 = 50.74

* For the second sale, there are 125 items in stock, 100 of these came from goods received on 2017/11/23, the remaining 25 come from the goods received on 2016/09/15.
The cost price should be ((100*30.25) + (25*28.72))/125

..(3025+718)/125 = 29.944

Any help on this greatly appreciated. I've managed to use our stock table to get as far as this but I'm struggling with how to implement this logic.

Thanks,

Colin.

0 Replies