Spreadsheet: 454035d1459605474-ifs-and-sums-and-nests-or-something-more-simple-example-2-2016-fifo
Sheet: Purchases

Bought |  |  | Sold | Closing Stock |  |  | Bought |  |  | Sold | Closing Stock |  |  | Bought |  |  | Sold | Closing Stock
 | Quantity | Price | Quantity | Quantity | Value |  |  | Quantity | Price | Quantity | Quantity | Value |  |  | Quantity | Price | Quantity | Quantity | Value
Open Stock | 562 | 3.87 |  |  |  |  | Open Stock | 112 | 3.77 |  |  |  |  | Open Stock | 20 | 1.02
Price 1 |  | 3.87 |  |  |  |  | Price 1 |  | 3.77 |  |  |  |  | Price 1 |  | 1.04
Price 2 |  | 6.3 |  |  |  |  | Price 2 |  | 3.9 |  |  |  |  | Price 2 |  | 1.12
Price 3 |  | 3.63 |  |  |  |  | Price 3 |  | 3.72 |  |  |  |  | Price 3 |  | 1.23
Price 4 |  | 3.8 |  |  |  |  | Price 4 |  |  |  |  |  |  | Price 4 |  | 1.16
Price 5 |  | 3.6 |  |  |  |  | Price 5 |  |  |  |  |  |  | Price 5
Price 6 |  |  |  |  |  |  | Price 6 |  |  |  |  |  |  | Price 6
Price 7 |  |  |  |  |  |  | Price 7 |  |  |  |  |  |  | Price 7
Price 8 |  |  |  |  |  |  | Price 8 |  |  |  |  |  |  | Price 8
Price 9 |  |  |  |  |  |  | Price 9 |  |  |  |  |  |  | Price 9
Totals |  |  |  |  |  |  | Totals |  |  |  |  |  |  | Totals
Column1 | Purchase Date | P/L No. | Running Total of Purchases | Units Bought | Unit Cost ex TAX |  | Column1 | Purchase Date | P/L No. | Running Total of Purchases | Units Bought | Unit Cost ex TAX |  | Column1 | Purchase Date | P/L No. | Running Total of Purchases | Units Bought | Unit Cost ex TAX
4 | 2015-04-09 00:00:00 | 387 |  | 1078 | 3.87 |  | 2 | 2015-04-09 00:00:00 |  |  | 20 | 3.77 |  | 6 | 2015-04-09 00:00:00 |  |  | 60 | 1.04
13 | 2015-05-11 00:00:00 | 388 |  | 1029 | 3.87 |  | 14 | 2015-05-11 00:00:00 |  |  | 25 | 3.77 |  | 18 | 2015-05-11 00:00:00 |  |  | 25 | 1.12
22 | 2015-06-12 00:00:00 | 390 |  | 49 | 6.3 |  | 20 | 2015-06-12 00:00:00 |  |  | 10 | 3.9 |  | 27 | 2015-06-12 00:00:00 |  |  | 5 | 1.23
23 | 2015-06-19 00:00:00 | 392 |  | 1078 | 3.87 |  | 24 | 2015-06-19 00:00:00 |  |  | 100 | 3.72 |  | 41 | 2015-06-19 00:00:00 |  |  | 20 | 1.16
30 | 2015-07-21 00:00:00 | 543 |  | 1078 | 3.8
39 | 2015-08-27 00:00:00 | 718 |  | 1078 | 3.8
45 | 2015-09-28 00:00:00 | 802 |  | 1078 | 3.8
47 | 2015-10-21 00:00:00 | 863 |  | 1078 | 3.8
60 | 2015-11-24 00:00:00 | 949 |  | 98 | 3.63
61 | 2015-11-25 00:00:00 | 972 |  | 1029 | 3.8
65 | 2015-12-22 00:00:00 | 1093 |  | 1078 | 3.8
67 | 2016-01-13 00:00:00 | 1115 |  | 539 | 3.6
2 | 2015-04-09 00:00:00 |  | Product 2 Name | 20 | 3.77
4 | 2015-04-09 00:00:00 | 387 | Product 1 Name | 1078 | 3.87
6 | 2015-04-09 00:00:00 |  | Product 3 Name | 60 | 1.04
13 | 2015-05-11 00:00:00 | 388 | Product 1 Name | 1029 | 3.87
14 | 2015-05-11 00:00:00 |  | Product 2 Name | 25 | 3.77
18 | 2015-05-11 00:00:00 |  | Product 3 Name | 25 | 1.12
20 | 2015-06-12 00:00:00 |  | Product 2 Name | 10 | 3.9
22 | 2015-06-12 00:00:00 | 390 | Product 1 Name | 49 | 6.3
23 | 2015-06-19 00:00:00 | 392 | Product 1 Name | 1078 | 3.87
24 | 2015-06-19 00:00:00 |  | Product 2 Name | 100 | 3.72
27 | 2015-06-12 00:00:00 |  | Product 3 Name | 5 | 1.23
30 | 2015-07-21 00:00:00 | 543 | Product 1 Name | 1078 | 3.8
39 | 2015-08-27 00:00:00 | 718 | Product 1 Name | 1078 | 3.8
41 | 2015-06-19 00:00:00 |  | Product 3 Name | 20 | 1.16
45 | 2015-09-28 00:00:00 | 802 | Product 1 Name | 1078 | 3.8
47 | 2015-10-21 00:00:00 | 863 | Product 1 Name | 1078 | 3.8
60 | 2015-11-24 00:00:00 | 949 | Product 1 Name | 98 | 3.63
61 | 2015-11-25 00:00:00 | 972 | Product 1 Name | 1029 | 3.8
65 | 2015-12-22 00:00:00 | 1093 | Product 1 Name | 1078 | 3.8
67 | 2016-01-13 00:00:00 | 1115 | Product 1 Name | 539 | 3.6
71 | 2016-02-12 00:00:00 | 1222 | Product 1 Name | 1078 | 3.6
76 | 2016-03-16 00:00:00 | 1376 | Product 1 Name | 539 | 3.6
80 | 2016-03-22 00:00:00 | 1396 | Product 1 Name | 1078 | 3.6