How to Calculate Dynamic FIFO Days-in-Inventory in Excel
Question details
The user needs to calculate the age of inventory using the First-In, First-Out (FIFO) method across dynamically changing sales and purchase data.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Managing an inventory spreadsheet where a single sale might consume stock from multiple previous purchase batches with varying purchase dates, requiring dynamic allocation logic.
- Observed behavior
- Simple row-by-row date subtraction fails to provide accurate inventory age because it cannot account for partial batch consumption across multiple historical purchase lots.
Ensure your purchase and sales data are organized in clean, chronological tables with dedicated columns for purchase dates, purchase quantities, sale dates, and sold quantities.
Build a FIFO Calculation Using Dynamic Array Functions
Utilize Excel's advanced dynamic array functions like LET, SCAN, MAP, and LAMBDA to dynamically allocate sold quantities to the oldest available purchase batches without using VBA.
A simple date subtraction is insufficient for FIFO inventory calculations because a single sale can pull stock from several different purchase lots. By using modern dynamic array functions, you can create a running total of sold inventory and map those sales against historical purchase dates to accurately calculate days in inventory.
Identify the cell ranges containing your Purchase Dates (e.g., A2:A10), Quantities Purchased (B2:B10), Sale Dates (C2:C10), and Quantities Sold (D2:D10).
Click on the first empty cell of the column where you want your FIFO Days-in-Inventory results to appear.
Type the formula starting with =LET() to define your variables. You will assign your ranges to logical names such as 'purchaseDates' and 'quantitiesSold' within the formula bar.
Inside your LET formula, integrate the SCAN function to track running totals of quantities sold, and use the MAP function paired with LAMBDA to calculate the difference between the sale date and the corresponding purchase dates for each allocated batch.
Press the Enter key on your keyboard to execute the formula. The dynamic array result will automatically spill down the column to display the inventory age for each batch.

Manage Complex Inventory Formulas with WPS Spreadsheet
WPS Office Spreadsheet fully supports advanced dynamic array functions natively, allowing you to perform complex FIFO inventory calculations effortlessly. Its intuitive interface helps you manage large datasets without lagging.
- 1. Install WPS Office: Download and install the free WPS Office suite from the official website onto your device.
- 2. Open Your Inventory File: Launch WPS Spreadsheet and open your existing Excel inventory tracking workbook (.xlsx).
- 3. Input the FIFO Formula: Select the target cell and type your dynamic array formula using LET, SCAN, and MAP directly into the formula bar.
- 4. Apply the Calculation: Press Enter to execute. WPS Spreadsheet will instantly calculate and spill the FIFO days-in-inventory results down your table.

Frequently Asked Questions
Why can't I just subtract the purchase date from the sale date to get days in inventory?
Simple subtraction works only if one sale perfectly matches one purchase batch. In real FIFO scenarios, a single sale often consumes remaining stock from an old batch and partial stock from a newer batch, meaning multiple purchase dates are involved in a single transaction.
What does the SCAN function do in this FIFO calculation?
The SCAN function iterates over an array of values (like your quantities sold) and applies an accumulator, allowing you to easily generate a running total. This is crucial for matching cumulative sales against cumulative purchases in FIFO tracking.
Can I perform FIFO tracking without using dynamic array functions?
Yes, but it is much more manual. You would need to set up several 'helper' columns to keep track of running totals for purchases and sales row-by-row, or you would need to write a custom VBA macro to iterate through the inventory allocations.
Does WPS Office support dynamic array formulas like LET and LAMBDA?
Yes, the latest versions of WPS Spreadsheet fully support dynamic array functions including LET, LAMBDA, MAP, and SCAN, ensuring seamless compatibility with modern Excel formulas.




