Function Problems

Create an Automatic Gain or Loss Column in an Excel Table

John WilsonJohn Wilson Nov 12, 2026 869 views

Question details

Create a calculated table column that subtracts planned tonnage from produced tonnage and stays blank if either source value is empty.

Create an Automatic Gain or Loss Column in an Excel Table
Product
Microsoft Excel table
Device & OS
not provided
Scenario
The user wants to compare planned and produced quantities for each row in a structured table.
Observed behavior
A positive value should indicate production above plan, a negative value should indicate a shortfall, and incomplete rows should display no result.
Before you start

Make sure the data is formatted as an Excel Table and that the headers are named Planned Tonnage and Produced Tonnage. Confirm that the quantity cells contain numbers when values are available.

Solution 1Recommended

Use an IF formula to calculate gain or loss only when both values exist

Use this formula in the new calculated column when you need each table row to show the produced-minus-planned difference without displaying zero or an error for incomplete records.

The formula checks whether either input cell is blank before performing the subtraction. Excel Table structured references automatically apply the formula to the rest of the calculated column.

1
Add a result column

In the Excel Table, insert a new column and enter a header such as Gain or Loss.

2
Enter the calculated-column formula

Select the first data cell under Gain or Loss and enter =IF(OR([@[Planned Tonnage]]="",[@[Produced Tonnage]]=""),"",[@[Produced Tonnage]]-[@[Planned Tonnage]]).

3
Apply the formula to the table

Press Enter. Excel should fill the formula down the calculated column automatically; if it does not, copy the formula down the remaining table rows.

4
Interpret the result

Review the Gain or Loss values: a positive number means produced tonnage exceeded the plan, while a negative number means production was below plan.

Use an IF formula to calculate gain or loss only when both values exist
Blank inputs remain blank: The formula returns an empty result when Planned Tonnage or Produced Tonnage is blank, rather than calculating a difference from an incomplete row.
Calculate planned versus produced quantities

Calculate Gain or Loss Automatically in WPS Spreadsheets

WPS Spreadsheets supports Excel-style tables and structured-reference formulas, so you can create a Gain or Loss column that compares produced and planned tonnage while leaving incomplete rows blank.

  1. 1. Open the workbook in WPS Spreadsheets: Launch WPS Office, choose Spreadsheets, and open the Excel workbook containing the planned and produced tonnage table.
  2. 2. Create the output field: Click the table header area, add a column beside the source values, and name it Gain or Loss.
  3. 3. Insert the blank-safe calculation: Select the first result cell and type =IF(OR([@[Planned Tonnage]]="",[@[Produced Tonnage]]=""),"",[@[Produced Tonnage]]-[@[Planned Tonnage]]).
  4. 4. Fill and review the results: Press Enter to apply the formula, then verify that positive values show gains, negative values show shortfalls, and rows with missing inputs remain blank.
Use IF and OR formulas to prevent results from appearing on incomplete rows.Calculate produced tonnage minus planned tonnage automatically for every table row.Open, edit, and save Microsoft Excel .xlsx and .xls spreadsheets with compatible formulas.Work in a lightweight spreadsheet interface with familiar table and formula tools.
microsoft office alternative - wps office

Frequently Asked Questions

Why does the Gain or Loss cell stay blank even though I entered one quantity?

The formula is designed to return a blank when either Planned Tonnage or Produced Tonnage is empty. Enter numeric values in both table columns to calculate the difference.

How do I show a loss as a negative number in an Excel table?

Subtract planned from produced: [@[Produced Tonnage]]-[@[Planned Tonnage]]. When produced tonnage is lower than planned tonnage, the result is negative automatically.

Can I use this formula if my table headers have different names?

Yes. Replace [@[Planned Tonnage]] and [@[Produced Tonnage]] with structured references matching your exact Excel Table column headers.

Why is Excel not filling the formula down the whole table column?

Enter the formula in the first data row of the table and press Enter. If automatic calculated columns are disabled, select the formula cell and drag or copy it down through the remaining rows.