4. Computed Columns

In the previous chapters, you have learned how to modify a table view so that rows are sorted in a particular order, and only rows meeting certain criteria are included. Now you will see how to enrich the table view with new information derived from the existing data.
Suppose you wish to display a new column called Value in the table in our example. The column should contain the total price of all copies of each album in stock (i.e. a product of the album price and the number of copies in stock). To do this, follow these steps:
In the table header, right-click the column next to which you wish to insert the new column. In the context menu, select the New Column… option.
In the dialog window, set Column insertion level to View. The contents of the window will change slightly to reflect the selected option:
Fill in the fields in the dialog window as follows:
name of the new column; must be an identifier. For example: value.
Data type
leave Computed in place.
Result data type
leave Real number in place.
Getter function
leave language set to Enki and enter the expression price * stock
Important note: the column names in the expression (price and stock) must start with a lowercase letter (they must be typed exactly as they were typed upon the table creation). Sfairadora is case-sensitive in column names. For purely aesthetic purposes, column names in table headers are capitalized regardless of the table definition.
Leave the default setting in place in all other fields.
When you have specified all information in the dialog, click the OK button. This creates the new column in the table. The resulting table will look like this:
A document containing the created table populated with data is stored in file Examples\Chapter 04.s-d.

Further Information

The following chapters of the Reference Guide contain detailed information on the discussed topic:
Enki Language – language used for the specification of expressions
Next: Save a View