Problem:

Columns A & B contain a log of all the sales from a particular day.
Each row consists of the name of an item and the quantity sold.
Columns D & E show the initial inventory for all items.
We want to create formulas in column F that will calculate the current inventory of each item. The formulas should update upon every sale added to the log.

Solution:

Use the SUMIF function in the following formula:
=E2-SUMIF($A:$A,D2,$B:$B)