You are here: Menu Commands > Database > Edit > Field Maths
GEOVIA Surpac

Field maths

This function evaluates complex expressions, and stores the result in an existing field. You can use it to perform calculations on any field in a table, but it can modify only fields that are not indexed. For example it cannot modify hole_id.

Prerequisites: A database is open.

To run this function: Choose Survey > Stations > Field maths, or Database > Edit > Field maths, or Design > Blast design > Edit > Field maths, or ...

  • In the Function Chooser, type FIELD MATHS, and press ENTER.

FIELD MATHS allows you to enter and process a maximum of 50 expressions one after the other. However, results are not committed to the database, until all the expressions have been evaluated. For example, the following two expressions will swap the contents of the two fields. Gold will be assigned the value in silver, and then silver will be assigned the original value of gold, not the updated value:

result field expression
gold silver
silver gold

Be aware that two expressions like the following will cause the gold field to contain the result of the second expression, as if the first expression did not exist:

result field expression
gold 10
gold gold+5

Note: If you are planning to carry out field maths on your database, it is best to have a spare field in the database table available to store the results, otherwise existing data may be overwritten.

Fields on the Database field maths form.

Field Description
Table name The name of the table that contains the fields on which you wish to perform maths. After you select a table, all fields in that table are displayed in the field list in the lower part of the form.
Result field

The name of the field in which to store the result of the expression. This field can be any data type but make sure it is the same type as the output of the expression. For example, do not have a result field of type real and try to store a character result in it. Result field cannot be an indexed field.

Note: All data already in the field you select will be overwritten. If necessary create a new field to use before you run FIELD MATHS.

Expression The expression to be evaluated. You can use any standard expression. Note that for field names containing non alpha-numeric characters (see naming restrictions), a special identifier must be used to ensure that the field name is recognised. Some example expressions are provided below. All fields in the selected table are available for use in the expression.
[field list] A list of all the fields in the table you selected.
Continue on errors?

If FIELD MATHS encounters an error when processing a row, that row is not processed.

  • Selected. FIELD MATHS continues to the next row and subsequent rows and attempts to process those rows.
  • Cleared. FIELD MATHS stops processing all rows.
Output Error Messages Outputs error messages to the Message window.

Table name

If the selected table is changed, so will the field names in the lower part of the form. However, if the table name is changed, all previously-entered expressions are cleared.

Expression Examples

Result Field Expression Outcome
grade 1.6 All values in grade field set to 1.6
rock_typ "LAT" All values in rock_typ field set to "LAT"
rock IIF(grade > 0.05, "ORE", "WASTE") If the grade is higher than 0.05 then the value of rock will be "ORE" otherwise it will be "WASTE"
depth_to depth_from + 5 All depth_to values will be set to their corresponding depth_from + 5
mat_avg (gold1 + gold2) / 2 average two fields

After you click Apply, the Define query constraints form appears allowing you to enter a collar constraint or other constraint.

Fields on the Define Query Constraints form

Field Description
Table name Read only. The name of the table you chose in the previous form.
Field name The name of the field on which you want to impose a constraint. If you leave Field name blank, all records in the table are selected.
Operand

The mathematical operation that defines the constraint. The operands are:

  • < less than
  • <= less than or equal to
  • > greater than
  • >= greater than or equal to
  • <> not equal to
  • = equal to
Constraint Value

The value for the constraint. Press TAB to add a second row, or right-click in the left column to add or remove constraint rows.

When you have multiple constraint rows, Surpac returns only the records that pass all the constraints. The only exception is that you can you use the hole_id field and the = operator to return multiple rows — in that situation, an OR operator is used between the two constraints. For example, the following constraint would return two records:

  • hole_id = WRC075
  • hole_id = WRC044

Examples:

For a surveying example, to select all the survey stations with a specific status, you could add a constraint:

  • status = C

The Constraint value for this constraint is C.

To select drillholes or survey stations in a particular area, you could add three constraints:

  • y < 9010.000
  • x > 2450.000
  • z >= 705.000

To select all of the holes where the collar is on a specific bench of an open pit, you could enter two constraints like these:

  • z > 149
  • z < 151
Load Loads a constraint from the .dbc file you choose. Be aware that a set of constraints is normally suitable for only the table on which it was created, or on tables that have the same or a very similar structure.
Save Saves the constraint to a .dbc file so you can reload it later.

Output

Result field is updated in the way that the expression specifies.

Errors

If an error occurs whilst attempting to perform field maths, error messages similar to the following are displayed.

Error evaluating expression for table assay with index(s) :

hole_id = WC001

depth_from = 16.4

Cannot update row in table assay with index(s) :

hole_id = WC001

depth_from = 16.4

If either of the previous messages occurs, it is very likely that the data for the row specified by the error message has corrupt values.