If quantity sold is greater than the target quantity,it should be balance of target quantity.If there is no balance in target quantity,it should be zero as i mentioned in column D for row13 & row 14.
There is a small error in the formula.I need your help.
Attached excel sheet for your reference.In this sheet Row11,actually row AR11 should be zero (Target for A (TOTAL) is one.Actual is two put together.So actual should be one only.
The formula I wrote was based on a fixed target as per your OP, now you have a dynamic target which change as per date which is a completely different scenario. I have tweaked the formula to accommodate this, you have to get your target data right for the formula to work. In your example you had given a target of 1 for Product A, in that case the formula will assume that the stock have been replenished hence it can use one more unit of Product A. If there is no additional unit available I guess you should keep the target as zero then the formula will return zero even if the quantity sold column have a number greater than zero. I hope this is what your business case is. Find the attached.
Dear Nebu,
I think i confused you.I am extremely sorry for that.what i did is i compared target (which is fixed for each quantity) but i compared in each line for actuals.It is similiar like FIFO (first in first out) method.I tried your latest formula what you shared also not working in my sheet.
Let say if target is one for Qty A,but actual are two,in first row it should be one (FIFO) and next row target should be zero.
I hope now you understand my query.