I have a query that is pulling data from two tables to give me my items by weeks of the year. For each week I have a projected usage by item. My query takes this date and puts in the quantity ordered instead of the projected usage when appropriate but I need it to take one more step.
I need my query to remove my projected usage quantity if I have had a subsequent order. So if in week 1 I had no orders, the query is putting in a projected usage #. This is good. But if I get an order in week 2, I need the # in week 1 changed to 0.
I haven’t been able to figure out what the iif statement should be to make this happen. It needs to be able to look back through the weeks and set the projected usage # to 0 for all weeks behind where an order is placed.
Item Projected Usage # Qty Ordered Week
1 10 10 1
2 10 10 1
1 10 20 2
2 10 15 2
In the above example, there are no orders for week one, so my query is putting the projected usage as the Qty Ordered. In week 2 there are orders, so now I need the Qty Ordered in week 1 to become 0 because they were just place holders until an actual order was placed.
Can you help?