Calculated column
This table contains one row for each calculated column.
Calculated columns come in addition to model columns, and don't require programming or database upgrades. Calculated columns exist only in the memory, not in the database, and are defined by formulas that typically refer to model columns.
Some entries in this table are used as a basis for creating Intrastat reports.
| Property | Value | Description |
|---|---|---|
| Database | System | This table is in the system (vbsys) database. |
| SQL name | CompCol | The table name in the database. |
| API identifier | calculatedColumn | The API identifier used in GraphQL. |
| Table no. | 238 | The table number in the data model. |
The following fields exist in this table:
Calc. column no.
A unique number identifying the calculated column.
The number will be used to refer to the calculated column in the layout tables, and must be in the interval 1 - 1 000 000.
| Property | Value | Description |
|---|---|---|
| Visible by default | Yes | This field is visible by default in the table display. |
| Domain | No. | Integer |
| Primary key | Yes | Calc. column no. |
| SQL name | CompCNo | The database field name. |
| API identifier | calculatedColumnNo | The API identifier used in GraphQL. |
| Number | 8412 |
Format
The display format of the calculated column.
- 0 - Float (Quantity)
- Floating-point values are shown with floating decimals by default. If you require fixed decimals, the number of decimals can be specified with the Format command (in the Column group in the Design tab).
- 1 - Date
- When using date fields in a formula, they represent the number of days since December 31st, 1979.
- 2 - Time
- When using time fields in a formula, they represent the number of minutes since midnight.
- 3 - String
- Selected when the output from the formula is a string value.
| Property | Value | Description |
|---|---|---|
| Visible by default | Yes | This field is visible by default in the table display. |
| Domain | Format | Integer |
| SQL name | Fmt | The database field name. |
| API identifier | format | The API identifier used in GraphQL. |
| Number | 9239 |
Formula
The calculation formula for the column.
Example: @Order (Your ref.)<>""
The formulas may include:
- Macro functions (with the prefix @),
- Numbers (integers or floating point numbers),
- Arithmetic operators (+, -, *, / and %),
- Relational operators (=, >, <, >=, <= and <>),
- Logical operators (!, && and ||),
- Conditions and partial expressions (?, :),
- Brackets (in an unlimited number of levels) and
- Tilde (~) for rounding.
Macro functions
The formula editor is initiated by typing the * character in, or double-clicking on, a table cell or form field. In the formula editor that opens, you can enter a formula by typing the @ symbol. A list of available macro functions is displayed.
Select the macro function you want to use, and using the macro parameter editor, you can select macro function parameters interactively. For example, if you select @FreeText(), a macro list of free text entries is displayed to choose from.
- @Column takes a field name as parameter, and can be chosen from the Field name dialog box that pops up if you double click on the macro, or select the macro and click the Field button. In this dialog box, you can choose among all columns in the table, and its underlaying tables. Several fields can be selected at the same time.
- @Date () and @Time () represent the current date and time.
- @SystemInteger, @SystemDecimal and @SystemText represent system dependent variables, and @CompanyInteger, @CompanyDecimal and @CompanyText company dependent variables. They all take a variable name as parameter, and optionally an element number. Element numbers should be in the interval 1 - 12 for integer and decimal variables, and 1 - 2 for text variables. Element numbers default to 1 if they are omitted. The Namespace for the variables are stated in a separate column in the table.
When you choose macro functions via lookup, they will be added to the end of the field (after a space if the field contains anything from before), instead of replacing the old content in the field. The field pointer will remain in the field, ready for editing.
Here are some examples of calculations with macros:
Calculated column
- @Column (Free 1) * @Column (Entered amount)
This field will show the value in the Free 1 field multiplied by the value in the Entered amount field. The field will be blank if nothing is entered in the Free 1 field.
Factors from general ledger
- @Column (Entered amount) * @Column (General ledger account [Account no.->Account no.] (Gr. 1))
This field will show a multiplication between the value in the Entered amount field and the value in the Gr. 1 field from the General ledger account table.
Calculated column 2
- @Column (Free 1) <> 0?@Column (Free 1) * @Column (Entered amount):1
If the value in the Free 1 field is different from 0, this field will show the value in the Free 1 field multiplied by the value in the Entered amount field.
If the value in the Free 1 field is 0, this field will show the value 1.
The ? following the first expression states the value to show if the expression is true; @Column (Free 1) * @Column (Entered amount). The : states the value to show if the expression is false; value 1.
Calculated column 3
- !@Column (Free 1) = 0?@Column (Free 1) * @Column (Entered amount):1
If the value in the Free 1 field is different from 0, this field will show the value in the Free 1 field multiplied by the value in the Entered amount field.
If the value in the Free 1 field is 0, this field will show the value 1.
The expression starts with !, which means NOT IDENTICAL. The ? following the first expression states the value to show if the expression is true; @Column (Free 1) * @Column (Entered amount). The : states the value to show if the expression is false; value 1.
This gives the same result as Calculated column 2.
Text fields act like a normal text field allowing to type, select text ranges and copy/paste text, while most of the formulas are editable as free text, macro functions are being displayed as tags and can’t be edited as free text. They are focused when moving the cursor with arrow keys or mouse clicks. When a macro function is focused, the macro editor is displayed.
Expression
When you use relational operators and/or logical operators, the expressions will return with 1 if true, or 0 if false.
Evaluation order
Parentheses will be evaluated first, and the operators will have the following priority:
- Multiplicative operators (*, / and %)
- Additive operators (+ and -)
- Rounding (~)
- Relational operators (=, >, <, >=, <= and <>)
- Negation (!)
- Conjunction (&&)
- Disjunction (||)
- Conditions and partial expressions (? and :)
Operators at the same level are evaluated from left to right.
Rounding the results inside the formula can be included with a tilde character (~) and a number. For example, ~1 would round the result to one decimal. Add brackets around the value and rounding parameters. Example: (10,55~1) = 10,60
The logical NOT operator (!) evaluates only the expression it is directly connected to, which means that a correct use of parentheses is important.
Examples
You have product no. HOURS - when this product is used on an order line the value in the Empl. no. field should be shown, otherwise not.
Valid use of ! in the formula (parentheses enclosing the whole expression to be evaluated):
- !(@Column (Product no.)="HOURS") ? 0 : @Column (Empl. no.)
Alternative formulas that gives the same result:
- @Column (Product no.)<>"HOURS" ? 0 : @Column (Empl. no.)
- @Column (Product no.)="HOURS" ? @Column (Empl. no.) : 0
The following formulas with ! won’t work (since the !@Column (Product no.) part will be evaluated before the =):
- !@Column (Product no.)="HOURS" ? 0 : @Column (Empl. no.)
- (!@Column (Product no.)="HOURS") ? 0 : @Column (Empl. no.)
Relevant error messages
In case you enter an incorrect formula or expression, the error is displayed below the text field.
| Property | Value | Description |
|---|---|---|
| Visible by default | Yes | This field is visible by default in the table display. |
| Domain | Formula | Unlimited text |
| SQL name | Form | The database field name. |
| API identifier | formula | The API identifier used in GraphQL. |
| Number | 8414 |
Name
The name of the calculated column.
The name can be seen in the Manage columns dialog box for the Unhide (Ctrl+U) command (in the table menu under View) for the table stated in the Table no. field. The name is used as the column heading, and can be overridden in Visible columns list.
| Property | Value | Description |
|---|---|---|
| Visible by default | Yes | This field is visible by default in the table display. |
| Domain | Name | Text (80) |
| SQL name | Nm | The database field name. |
| API identifier | name | The API identifier used in GraphQL. |
| Number | 8413 |
Namespace
The namespace for variables used in macro functions in the formula.
| Property | Value | Description |
|---|---|---|
| Visible by default | No | This field is not visible by default in the table display. |
| Domain | GUID | Text (40) |
| SQL name | NmSp | The database field name. |
| API identifier | namespace | The API identifier used in GraphQL. |
| Number | 10780 |
| To table | Purpose | From columns | To columns | Comments |
|---|---|---|---|---|
| Namespace | Namespace |
|
Table no.
The table the calculated column applies to.
You can select a table by looking up in this field.
| Property | Value | Description |
|---|---|---|
| Visible by default | Yes | This field is visible by default in the table display. |
| Domain | Table no. | Integer |
| SQL name | TabNo | The database field name. |
| API identifier | tableNo | The API identifier used in GraphQL. |
| Number | 8411 |
Control columns
Control columns include information about who has changed the record last and when, and which process that is currently editing the record.
Changed by provenance
The provenance for the record change.
A look-up in this field gives you the following list of possible values:
0 - None
1 - UI
10 - External API
20 - GAiA
21 - AI Connect
100 - Internal service
101 - Task automation
102 - AutoInvoice download
| Property | Value | Description |
|---|---|---|
| Visible by default | No | This field is not visible by default in the table display. |
| Domain | Provenance | Integer |
| Write Access | None | You are not allowed to modify the value in this field. |
| SQL name | ChPvn | The database field name. |
| API identifier | changedByProvenance | The API identifier used in GraphQL. |
| Number | A unique column number. |
Changed by user
The name of the user that changed the record.
| Property | Value | Description |
|---|---|---|
| Visible by default | No | This field is not visible by default in the table display. |
| Domain | User name | Text (24) |
| Write Access | None | You are not allowed to modify the value in this field. |
| SQL name | ChUsr | The database field name. |
| API identifier | changedByUser | The API identifier used in GraphQL. |
| Number | A unique column number. |
Changed date
The date when the record was changed.
| Property | Value | Description |
|---|---|---|
| Visible by default | No | This field is not visible by default in the table display. |
| Domain | Date | Integer |
| Write Access | None | You are not allowed to modify the value in this field. |
| SQL name | ChDt | The database field name. |
| API identifier | changedDate | The API identifier used in GraphQL. |
| Number | A unique column number. |
Changed time
The time when the record was changed.
| Property | Value | Description |
|---|---|---|
| Visible by default | No | This field is not visible by default in the table display. |
| Domain | Time | Integer |
| Write Access | None | You are not allowed to modify the value in this field. |
| SQL name | ChTm | The database field name. |
| API identifier | changedTime | The API identifier used in GraphQL. |
| Number | A unique column number. |
Changed time stamp
The date and time when the record was changed.
The field is updated with the UTC time.
This value can be used by external systems to replicate changed data. The column is indexed.
| Property | Value | Description |
|---|---|---|
| Visible by default | No | This field is not visible by default in the table display. |
| Domain | Date/time | DateTime |
| Write Access | None | You are not allowed to modify the value in this field. |
| SQL name | ChTs | The database field name. |
| API identifier | changedTimestamp | The API identifier used in GraphQL. |
| Number | A unique column number. |
Created by provenance
The provenance for the record creation.
A look-up in this field gives you the following list of possible values:
0 - None
1 - UI
10 - External API
20 - GAiA
21 - AI Connect
100 - Internal service
101 - Task automation
102 - AutoInvoice download
| Property | Value | Description |
|---|---|---|
| Visible by default | No | This field is not visible by default in the table display. |
| Domain | Provenance | Integer |
| Write Access | None | You are not allowed to modify the value in this field. |
| SQL name | CrePvn | The database field name. |
| API identifier | createdByProvenance | The API identifier used in GraphQL. |
| Number | A unique column number. |
Created by user
The name of the user that created the record.
| Property | Value | Description |
|---|---|---|
| Visible by default | No | This field is not visible by default in the table display. |
| Domain | User name | Text (24) |
| Write Access | None | You are not allowed to modify the value in this field. |
| SQL name | CreUsr | The database field name. |
| API identifier | createdByUser | The API identifier used in GraphQL. |
| Number | A unique column number. |
Created date
The date when the record was created.
| Property | Value | Description |
|---|---|---|
| Visible by default | No | This field is not visible by default in the table display. |
| Domain | Date | Integer |
| Write Access | None | You are not allowed to modify the value in this field. |
| SQL name | CreDt | The database field name. |
| API identifier | createdDate | The API identifier used in GraphQL. |
| Number | A unique column number. |
Created time
The time when the record was created.
| Property | Value | Description |
|---|---|---|
| Visible by default | No | This field is not visible by default in the table display. |
| Domain | Time | Integer |
| Write Access | None | You are not allowed to modify the value in this field. |
| SQL name | CreTm | The database field name. |
| API identifier | createdTime | The API identifier used in GraphQL. |
| Number | A unique column number. |
Created time stamp
The date and time when the record was created.
The field is updated with the UTC time.
| Property | Value | Description |
|---|---|---|
| Visible by default | No | This field is not visible by default in the table display. |
| Domain | Date/time | DateTime |
| Write Access | None | You are not allowed to modify the value in this field. |
| SQL name | CreTs | The database field name. |
| API identifier | createdTimestamp | The API identifier used in GraphQL. |
| Number | A unique column number. |
Edit status
The current status of the record.
A look-up in this field gives you the following list of possible values:
0 - Unchanged: The record is read, but not changed.
1 - Inserted: The record is new.
2 - Changed: The record is changed.
3 - Deleted: The record is deleted.
| Property | Value | Description |
|---|---|---|
| Visible by default | No | This field is not visible by default in the table display. |
| Domain | Edit status | Integer |
| Write Access | None | You are not allowed to modify the value in this field. |
| SQL name | LckSt | The database field name. |
| API identifier | editStatus | The API identifier used in GraphQL. |
| Number | A unique column number. |
Process no
The Process no. from the Active company process table which is currently using or has control of this record.
| Property | Value | Description |
|---|---|---|
| Visible by default | No | This field is not visible by default in the table display. |
| Domain | Process no. | Integer |
| Write Access | None | You are not allowed to modify the value in this field. |
| SQL name | ChPrc | The database field name. |
| API identifier | lockedByProcessNo | The API identifier used in GraphQL. |
| Number | A unique column number. |
| To table | Purpose | From columns | To columns | Comments |
|---|---|---|---|---|
| Active company process | CompanyProcess | Process no. | Process no. |