Calculation tables allow real time calculations, in tabular form, to be carried out during a specification.
Data from form controls can be used in the table and results can be returned to other form controls.
Rules can be built for each cell in the table, and these rules can reference other cells in the table either using an absolute reference or a relative reference.
From DriveWorks Administrator, and with a project open, go to Stage 3: Data and Rules > Calculation Tables:
The Edit Calculation Table dialog will open.
Columns are set to be a specific type, these can be:
Data type columns allow set values or rules to be entered.
Control Input type columns will take the value from a set of corresponding controls (see Form Control Name Matching below).
Control Output type columns allow set values or rules to be entered, and will return the result to a set of corresponding controls (see Form Control Name Matching below).
Columns set to be of the type Control Input and Control Output will have their column name matched to a form control.
Name matching will append the row number to the column name and look for a control with that name.
When a column with the name PanelWidth has been added to the Calculation Table;
And the Calculation Table has 4 rows;
The form controls PanelWidth1, PanelWidth2, PanelWidth3, and PanelWidth4 must exist on a user form.
When using a Control Output column, the Set Output Control Rules button will need to be clicked to update the rules in the controls if the rule is added or changed.
DriveWorks will detect a corresponding name has been added and will present a grey indicator in the corner of the applicable cells.
The Calculation Table will display the Control Names Return value in normal viewing mode.
Rules can be built for any column of the type Data or Control Output.
There are 2 types of rule that can be built:
When the calculation table is selected, Cell rules are built by:
When the calculation table is selected, Column rules are built by:
When rows are added to the Calculation table, Column Rules will apply to each cell in the column.
When building cell rules, using the result of another cell is done by using relative referencing.
Taking the position of the cell requiring the result (the cell having the rule built) as a starting point:
Each co-ordinate is placed within square brackets , and separated with a comma ,
So for example to get the value of a cell 3 down and 2 left, the reference would look like:
To get the value of a cell immediately to the right of the current cell, the reference would be:
And to multiply the above two cells together the rule would be:
[3d,2l] * [1r]
Any cell can referenced directly from any rule in DriveWorks.
For example, the following rule references the 3rd cell down, in the Total column of the Prices table.
="Total Price: " & DWCalcPrices.Total3
While writing cell rules, you do not have to prefix these references with the table reference (e.g. DWCalcPrices) - so long as you want to reference a cell that is in the same table. I.e. you can just reference another cell via Price3 (assuming you have a column called Price and you have at least 3 rows in your table).
These cell references can possibly override your ability to reference controls (and other items, if you get creative with naming your columns), as the references have the same name. e.g. If you have a cell called Price3 and a control called Price3, a cell rule reference just written as Price3 will reference the cell, not the control.
You can prefix references with exclamation marks (!) to ensure that you are referencing a control or any other "root" item. E.g. !Price3 will not reference a cell, but will reference a control.
Will rename the selected Calculation Table.
Will delete the selected Calculation Table.
Allows existing columns to be edited, or more columns added.
Will add rows to the selected Calculation Table.
Will match Control Output type columns in the selected Calculation Table to Form Control names that have been added.
This will set the Text or Text (Override) property of any form control that has the name of the column in the Calculation Table, proceeded with the row number, with a rule that references the Calculation Table and cell.
This toggles the view of the selected Calculation table between: