Selective calculation

I would like to find the average cost of a particular item, searched on the calc sheet,
ie A2 = Item code / B2 = cost value / C2 = average purchase price / D2 auto adjusts if input says ‘Sold’ so that Stock Level does not count any sold item.

How would I create that ?
test example.ods (12.4 KB)

I won’t dare claim to have understood the question and the example.
However: The function AVERAGEIFS() might be your friend.

1 Like

Me too. Anyway:

=AVERAGEIFS(B2:B99,A2:A99,A2,D2:D99,"Stock")
image