Add a calculated field
In this task you add a column to the table of a report. Its value in each row comes from a formula that uses the other columns of the same row, for example the difference between two amounts. The new column is part of the report window: it does not change any data in the program.
Before you begin
- This page is for ordinary tables. For a pivot table, see Calculated fields in a pivot table.
- Run a report that shows a table. See Run a report and read the result.
- Click inside the table.
- Know which columns the formula needs. You choose them from a list, so you do not type their internal names.
- If you only need a column for notes, use Add Column instead. It adds an empty column that you fill by hand.
Steps
- Click Tools > Data > Manage Calculated Fields. The window Manage Calculated Fields opens and lists the fields that already exist.
- Click New. The window Add Calculated Field opens.
- In Name, type an internal name in English letters without spaces, for example
Diff. You cannot change the name later. - In Title, type the header of the new column, for example
Difference. - In Format, choose how to show the result: Balance, Price, Quantity and Integer for numbers, Percent for a percentage, Date for a date, Boolean for yes or no, or Text. Text is the default, so change it for a number: in the example choose Balance.
- Click the button at the end of the Expression box. The Expression Editor opens.
- Write the formula. Double-click a column in the list of columns to insert it, and type the operator after it. A column appears between square brackets. For example, in the Trial Balance
[DebitBalance] - [CreditBalance]gives the difference between the debit balance and the credit balance. The names in your report may differ. Insert the columns with a double-click and do not type their names: the editor marks a name it does not know as "Invalid column".- To use the total, the average, the count, the highest or the lowest value of a column, use
SumOf([Column]),AvgOf([Column]),CountOf([Column]),MaxOf([Column])orMinOf([Column])with one column name. These functions work on numeric columns with no empty cells. Otherwise the field shows0in every row. They use the rows left after filtering.
- To use the total, the average, the count, the highest or the lowest value of a column, use
- Click Ok in the editor. It is disabled while the formula has an error that the editor marks.
- Click Ok in the field window. The program checks the fields in order and shows a message at the first problem. See If something goes wrong.
- Click Ok in Manage Calculated Fields.
- To keep the field, save the workspace with Save (
Ctrl+S).


Change or delete a field
- Open Manage Calculated Fields.
- To change a field, select it and click Edit, or double-click it. You can change the title, the format and the expression. The name stays as it is.
- To delete a field, select it, click Delete and click Yes to the question. If another calculated field uses it, the program refuses and lists those fields: change or delete them first.
- Click Ok.
Changes and deletions apply when you click Ok in the main window. Cancel leaves the table as it was.
Result
The new column appears at the end of the table, and in the Field List panel. For example, in the Trial Balance the row 1231-Notes Receivable has 7,000.00 in Debit balance and 0.00 in Credit balance, so Difference shows 7,000.00. The row 1212-Alnakheel Est. has 0.00 and 15,948.00, and Difference shows 15,948.00-: the minus sign comes after the number in the Balance format. You can sort, group, summarize and format the new column. Search does not skip it: a search that includes a visible calculated field ends in an error window, so clear its box in Search Fields before you search. The field is part of the page layout, so it is lost when the viewer closes unless you save the workspace.

If something goes wrong
| Message or problem | Why it happens | What to do |
|---|---|---|
| "'…' is required field." | Name, Title or Expression is empty. | Fill the field named in the message. |
| "Field name must be in English and doesn't contain spaces." | The name has a space or a character that is not English. | Use English letters, digits and the underscore only. |
| "Name is already used." | Another calculated field or a column has this name. | Choose a different name. |
| "The calculated field can't be deleted because it is used by the following calculated fields:" | Another calculated field uses this one in its formula. | Edit or delete the fields listed, then delete this one. |
The new cells show 0. | The formula cannot be calculated for the row, for example a column name is wrong. SumOf and the other aggregate functions show 0 in every row if the column is text or has an empty cell. The program shows no message. | Open the field with Edit, check the formula in the editor and choose the columns from the list. |
| A number looks like plain text, without thousands separators. | The format is Text. | Edit the field and choose a number format. |
| The button Manage Calculated Fields is missing. | The report does not allow summaries for this table. | The report does not offer calculated fields. |
Related
- Report grid tools: the windows used here
- Sort, group and summarize a grid
- Apply conditional formatting
- Pivot table tools
This page applies to alameen ERP 10, version 10.1.79.764.