Tips & Tricks - Calculation

This article explains how to perform calculations in view tables using the formula editor.

Summary calculation

With this type of calculation, the calculated value is output below a table column.

First create a new application with the "Basic application" template.

You will find a view table on the "All entries" page. For the calculations we use a floating-point number data field, which is integrated in the table. Switch to the "Entry" input page.

Double-click on the grid line in which the "Title" input field is located to switch to the zoom area.

Create a new input field below the title. The properties dialog opens automatically.

Select the option "New data field" and click "Next".

Give the new input field the title "Value" and select the control type "Floating point number". Click "Next". After the following final settings, click on "Finish".

Switch back to the "All entries" page and open the properties dialog for the view table.

On the "All entries" page (1), double-click to open the properties dialog for the view table (2). Click on "Add column" (3) to add the new data field "Value" (4). General information on creating a new table column can be found here.

Save the change by clicking on "OK".

Confirm the properties dialog of the view table by clicking on "OK" and then open the properties dialog again.

Click on "Edit area for total calculation".

Select the cell below the "Value" column and click on "Add control".

Then select "Calculation" from the menu that appears.

The formula can now be created by clicking on "Edit control".

Enter a title here and click on "Edit formula".

The library contains a collection of Intrexx formulae. In the "Functions" category, select

"Table functions / Aggregate functions for column values / Column values of data records (current view) / Total"

the formula "Sum of control". The formula

            sum(table("<tableGuid>"), row("<tableControlGuid>", <fallbackValue>))
        

can be added to the workspace of the editor by double-clicking on it.

If the "Application structure" tab is not visible in the right-hand area next to "Libraries", show it via the "View / Application structures" menu.

In the application structure, you will find the view table under "All entries / FormGroup / Grid / Container 2".

Select the "tablerecords" entry there.

Replace the <tableGuid> part of the formula with the GUID shown below. To do so, simply select the part of the formula in the workspace and then double-click on the GUID under the application structure. The GUID is then automatically inserted and overwrites the selected part of the formula.

Replace the <tableControlGuid> part with the GUID of the "Value" control.

An optional fallback value is not required in our example - this can be removed from the formula.

Close all open dialogs by clicking on "OK", save the application and test the result in the browser by entering values in the application.

Calculation in separate table column

It is also possible to create a separate table column for the calculation - e.g. as in the illustration above with the same formula, which then outputs the total per row in the "Value 2" column.

For the type of calculation, simply select the "Calculation" menu when creating a new table column. The steps that follow are already familiar from the summary calculation.

More information

View table - Calculations

Formula editor