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.

PropertyValueDescription
DatabaseSystemThis table is in the system (vbsys) database.
SQL nameCompColThe table name in the database.
API identifiercalculatedColumnThe API identifier used in GraphQL.
Table no.238The 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.

Note:
If you press + in this field, the next available number is suggested. Gaps in the number series resulting from any deleted rows are not suggested. If you enter an existing number you will receive an error message. The number cannot be changed once it is entered.
PropertyValueDescription
Visible by defaultYesThis field is visible by default in the table display.
DomainNo.Integer
Primary keyYesCalc. column no.
SQL nameCompCNoThe database field name.
API identifiercalculatedColumnNoThe API identifier used in GraphQL.
Number8412 

Format

The display format of the calculated column.

A look-up in this field gives you the following list of possible values:
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.
PropertyValueDescription
Visible by defaultYesThis field is visible by default in the table display.
DomainFormatInteger
SQL nameFmtThe database field name.
API identifierformatThe API identifier used in GraphQL.
Number9239 

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:

  1. Multiplicative operators (*, / and %)
  2. Additive operators (+ and -)
  3. Rounding (~)
  4. Relational operators (=, >, <, >=, <= and <>)
  5. Negation (!)
  6. Conjunction (&&)
  7. Disjunction (||)
  8. 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.

PropertyValueDescription
Visible by defaultYesThis field is visible by default in the table display.
DomainFormulaUnlimited text
SQL nameFormThe database field name.
API identifierformulaThe API identifier used in GraphQL.
Number8414 

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.

PropertyValueDescription
Visible by defaultYesThis field is visible by default in the table display.
DomainNameText (80)
SQL nameNmThe database field name.
API identifiernameThe API identifier used in GraphQL.
Number8413 

Namespace

The namespace for variables used in macro functions in the formula.

Note:
If you double-click or press * in this field, you can look up a value in the related table.
PropertyValueDescription
Visible by defaultNoThis field is not visible by default in the table display.
DomainGUIDText (40)
SQL nameNmSpThe database field name.
API identifiernamespaceThe API identifier used in GraphQL.
Number10780 
Table 1. Table relations
To tablePurposeFrom columnsTo columnsComments
NamespaceNamespace
  • Namespace

Table no.

The table the calculated column applies to.

You can select a table by looking up in this field.

PropertyValueDescription
Visible by defaultYesThis field is visible by default in the table display.
DomainTable no.Integer
SQL nameTabNoThe database field name.
API identifiertableNoThe API identifier used in GraphQL.
Number8411 

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

PropertyValueDescription
Visible by defaultNoThis field is not visible by default in the table display.
DomainProvenanceInteger
Write AccessNoneYou are not allowed to modify the value in this field.
SQL nameChPvnThe database field name.
API identifierchangedByProvenanceThe API identifier used in GraphQL.
NumberA unique column number. 

Changed by user

The name of the user that changed the record.

PropertyValueDescription
Visible by defaultNoThis field is not visible by default in the table display.
DomainUser nameText (24)
Write AccessNoneYou are not allowed to modify the value in this field.
SQL nameChUsrThe database field name.
API identifierchangedByUserThe API identifier used in GraphQL.
NumberA unique column number. 

Changed date

The date when the record was changed.

PropertyValueDescription
Visible by defaultNoThis field is not visible by default in the table display.
DomainDateInteger
Write AccessNoneYou are not allowed to modify the value in this field.
SQL nameChDtThe database field name.
API identifierchangedDateThe API identifier used in GraphQL.
NumberA unique column number. 

Changed time

The time when the record was changed.

PropertyValueDescription
Visible by defaultNoThis field is not visible by default in the table display.
DomainTimeInteger
Write AccessNoneYou are not allowed to modify the value in this field.
SQL nameChTmThe database field name.
API identifierchangedTimeThe API identifier used in GraphQL.
NumberA 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. 

PropertyValueDescription
Visible by defaultNoThis field is not visible by default in the table display.
DomainDate/timeDateTime
Write AccessNoneYou are not allowed to modify the value in this field.
SQL nameChTsThe database field name.
API identifierchangedTimestampThe API identifier used in GraphQL.
NumberA 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

PropertyValueDescription
Visible by defaultNoThis field is not visible by default in the table display.
DomainProvenanceInteger
Write AccessNoneYou are not allowed to modify the value in this field.
SQL nameCrePvnThe database field name.
API identifiercreatedByProvenanceThe API identifier used in GraphQL.
NumberA unique column number. 

Created by user

The name of the user that created the record.

PropertyValueDescription
Visible by defaultNoThis field is not visible by default in the table display.
DomainUser nameText (24)
Write AccessNoneYou are not allowed to modify the value in this field.
SQL nameCreUsrThe database field name.
API identifiercreatedByUserThe API identifier used in GraphQL.
NumberA unique column number. 

Created date

The date when the record was created.

PropertyValueDescription
Visible by defaultNoThis field is not visible by default in the table display.
DomainDateInteger
Write AccessNoneYou are not allowed to modify the value in this field.
SQL nameCreDtThe database field name.
API identifiercreatedDateThe API identifier used in GraphQL.
NumberA unique column number. 

Created time

The time when the record was created.

PropertyValueDescription
Visible by defaultNoThis field is not visible by default in the table display.
DomainTimeInteger
Write AccessNoneYou are not allowed to modify the value in this field.
SQL nameCreTmThe database field name.
API identifiercreatedTimeThe API identifier used in GraphQL.
NumberA unique column number. 

Created time stamp

The date and time when the record was created.

The field is updated with the UTC time.

PropertyValueDescription
Visible by defaultNoThis field is not visible by default in the table display.
DomainDate/timeDateTime
Write AccessNoneYou are not allowed to modify the value in this field.
SQL nameCreTsThe database field name.
API identifiercreatedTimestampThe API identifier used in GraphQL.
NumberA 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.

PropertyValueDescription
Visible by defaultNoThis field is not visible by default in the table display.
DomainEdit statusInteger
Write AccessNoneYou are not allowed to modify the value in this field.
SQL nameLckStThe database field name.
API identifiereditStatusThe API identifier used in GraphQL.
NumberA unique column number. 

Process no

The Process no. from the Active company process table which is currently using or has control of this record.

Note:
If you double-click or press * in this field, you can look up a value in the related table.
PropertyValueDescription
Visible by defaultNoThis field is not visible by default in the table display.
DomainProcess no.Integer
Write AccessNoneYou are not allowed to modify the value in this field.
SQL nameChPrcThe database field name.
API identifierlockedByProcessNoThe API identifier used in GraphQL.
NumberA unique column number. 
Table 2. Table relations
To table Purpose From columns To columns Comments
Active company process CompanyProcess Process no. Process no.