Formulas
Formulas enable you to reuse a numerical computation in different locations. Instead of writing the same expression for each cell that uses it, you can use a named formula. Complex computations can be stored under a unique name in order to make them reusable throughout the knowledge base.
Formulas can be used to reuse a numerical computation in different locations. Instead of writing the same expression for each cell that uses it (using keyword EVAL), you can use a named formula. It serves as a kind of digital calculator, but one where complex computations can be stored under a unique name in order to make them reusable throughout the knowledge base.
A formula consists of a name, a body and comments. A formula must be parameterized by including one or more comma separated arguments (parameters) inside parentheses at the end of the name:
FahrenheitToCelsius (Temp)
The body contains the calculation, including the arguments (parameters) defined in the name:
(5/9) x (Temp – 32)
Comments are optional and can be used as a description to document the expression.
Working with Formulas
By using the keyword EVAL, you can create calculations where
one or more values of the expression might be unknown until the knowledge base is consulted. This is also true for the named formulas described in this chapter. A variable can be used in a formula by passing it as a parameter after a value has been assigned to it. No matter what the origin of the value is, it is important that the variable is of the domain type Quantitative. Even though a Qualitative variable with a numeric value might work, it is unsafe to use since a qualitative variable could contain other characters that will produce a false answer. Therefore, a qualitative variable used as parameter will result in an error during the Integrity Check.
The advantage of named formulas becomes clear when you have a large number of calculations in your knowledge base performing the same computation. By using one named formula instead of several EVAL operations, you will not only save time, but the knowledge base will also benefit by:
- Increased readability – A human reader understands a descriptive name faster than the equivalent EVAL expression.
- Increased reliability – The same expression is used for all computations which makes it easier to update and less prone to typing errors.
All of the named formulas that exist for your knowledge base are listed under the tab Formulas in the navigator. From the navigator it is possible to choose a formula in order to view, change or delete it.
Viewing and Changing the Properties
- In the navigator, double-click the formula of interest to open the Formula properties dialogue window. You can also right- click the formula and select Open Formula.
- The properties window is opened. Here you can either view or change the formula’s name, body and/or comments. Changes applied to the formula must follow the same rules as when creating a new formula.
- Save your changes by clicking Save Changes. To close the expression properties without saving, click Cancel.