Using the calculated data type in a table

You can use the calculated data type to perform calculations with values from fields in the same table. You can also perform calculations using fields from different tables by joining these fields in a relation (see Using the calculated data type in a relation).

The following example should make it clear to you how to perform calculations in a single table.

Imagine you have a table that contains fields for the product ID, the quantity in stock of each product, and the cost of each product:

Product _ID

Quantity

Cost

StockValue

A001

5

27.99

139.95

A002

7

45.50

318.50

A003

4

20.00

80.00

A004

6

8.99

53.94

You want to add the extra column to calculate the total value of each product in stock. Follow these steps:

  1. If you are already in your table, select Table from the Format menu to display the "Format table" dialog.

  2. In "Format table" go to the next empty line. Type "StockValue" in the Name column and select Calculated in the Type column.

  3. Click on the Format button to display the "Format Field" dialog.

  4. On the Format page select either Number or Currency and make sure Decimal Places is set at 2.

  5. On the Formula page type the following in the Formula line:

      =Quantity * Cost

  6. Click on OK to return to "Format table".

  7. Click on OK to return to your table.

The table will be redrawn to show the result of the calculation, for each record, in the StockValue column.