Formula Errors

How to Calculate Remaining Quantity by Code and Order Number in Excel

Nimra MalikNimra Malik Nov 10, 2026 868 views

Question details

The user needs to calculate the remaining quantity of items required for specific orders by matching both an item code and an order number.

How to Calculate Remaining Quantity by Code and Order Number in Excel
Product
Excel
Device & OS
not provided
Scenario
Inventory or order management where produced or completed quantities must be subtracted from total ordered quantities across multiple specific orders.
Observed behavior
The user wants a dynamic formula that matches multiple criteria (Code and Order Number) to correctly calculate the outstanding required balance without yielding negative numbers.
Before you start

Ensure your data is organized into clearly labeled columns, ideally formatted as an Excel Table, with columns for Code, Order Number, Ordered Quantity, and Produced Quantity.

Solution 1Recommended

Use SUMIFS to Calculate Remaining Quantity

Utilize the SUMIFS function to sum the ordered quantities and subtract the produced quantities based on multiple criteria (Code and Order Number).

The SUMIFS function allows you to sum values based on multiple conditions. By using two SUMIFS functions—one to find the total ordered and one to find the total produced—you can easily calculate the difference.

1
Identify your criteria cells

Locate the cells containing the specific Code and Order Number you want to calculate the remaining quantity for (e.g., cell A2 for Code, B2 for Order Number).

2
Write the first SUMIFS formula

Enter the formula to get the total ordered quantity: =SUMIFS(Orders[OrderedQty], Orders[Code], A2, Orders[OrderNo], B2). Adjust the table and column names to match your workbook.

3
Subtract the produced quantity

Add the subtraction part of the formula using a second SUMIFS: -SUMIFS(Orders[ProducedQty], Orders[Code], A2, Orders[OrderNo], B2).

4
Combine and execute

Your complete formula should look like: =SUMIFS(Orders[OrderedQty], Orders[Code], A2, Orders[OrderNo], B2) - SUMIFS(Orders[ProducedQty], Orders[Code], A2, Orders[OrderNo], B2). Press Enter to view the result.

Use SUMIFS to Calculate Remaining Quantity
Prevent Negative Values: To prevent the result from showing negative quantities if over-production occurs, wrap your entire formula inside the MAX function, like this: =MAX(0, [Your Formula]).
Manage Inventory Effortlessly

Calculate Remaining Quantities Quickly in WPS Spreadsheet

WPS Spreadsheet fully supports SUMIFS, MAX, and advanced table features, allowing you to manage complex inventory and order calculations with ease.

  1. 1. Open your workbook: Launch WPS Spreadsheet and open your inventory or order tracking document.
  2. 2. Select the calculation cell: Click on the cell where you want the remaining quantity to appear.
  3. 3. Input the formula: Type your =SUMIFS() formula to subtract the produced items from the ordered items based on your code and order number.
  4. 4. Fill the column: Press Enter to calculate the result, then drag the fill handle down to apply it to your entire list.
Fully compatible with Microsoft Excel (.xlsx) formats and formulas.Advanced functions like SUMIFS and MAX run smoothly for accurate calculations.Lightweight software with a familiar, easy-to-navigate tabbed interface.Free to use with built-in templates for inventory and order management.
microsoft office alternative - wps office

Frequently Asked Questions

Why is my SUMIFS formula returning a #VALUE! error?

This usually happens if the range sizes in your formula do not match. Ensure that the sum_range and criteria_ranges all cover the exact same number of rows and columns.

Can I add a third condition, like a Date or Customer Name?

Yes, SUMIFS can handle up to 127 criteria pairs. Simply add another comma after your last criteria, select the new criteria range, add another comma, and specify the new condition.

What if my 'Produced Quantity' cell is blank instead of zero?

SUMIFS treats blank cells as zero when summing. Your formula will still calculate correctly, and the remaining quantity will simply equal the total ordered quantity.