---
title: "Quality Inspector Expression Examples"
app: "Quality Inspector"
section: "Set up"
last_updated: "2026-09-18"
url: "https://insight-works.com/kb/quality-inspector/quality-inspector-expression-examples/"
---

# Quality Inspector Expression Examples

Quality Inspection tests can use expressions to dynamically calculate values. These include information from the test itself, other test measurements, and table lookups. You can use the values to calculate the test value, the allowable values, and/or the pass condition for the measurement.

The expressions use the Insight Works Expression Evaluator, part of the Insight Works Rule Builder library.  More information on general use of the expression syntax and built-in mathematical functions are available here: [https://kb.dmsiworks.com/knowledge-base/expression-evaluator/](/kb/product-configurator/expression-evaluator/)

### Test information

Inbuilt references to test information use the syntax [FieldName] where FieldName is the name of the test field. For example, [Description] would reference the test’s description.

### Inspection fields

An inspection field can reference other fields on the test (e.g., when the measured value of one field influences the expected outcome of another field).

The syntax is “[FIELDCODE]” where FIELDCODE is the inspection field to be referenced. For example, if the PACKAGEWIDTH should be greater than the PACKAGEHEIGHT, the pass condition for package width would be “>[PACKAGEHEIGHT]”. For examples of using the value of one field to dynamically update the pass conditions for other fields, see the _[Create an Inspection Checklist with an Override Checkbox](/kb/quality-inspector/create-an-inspection-checklist-with-an-override-checkbox/) _and [_Use__embedded expressions within acceptable values and pass conditions_](/kb/quality-inspector/use-embedded-expressions-within-acceptable-values-and-pass-conditions/) pages.

### Numeric expressions

Quality Inspector uses the Insight Works’ Rule Builder library to evaluate numeric expressions. See the _[Expression Evaluator](/kb/product-configurator/expression-evaluator/)_page for a complete list of the numeric expressions that are supported.

### Special table lookup expressions

The special table lookup expressions allow you to use inbuilt references to common related records using the syntax “[SpecialTable:FieldName]”. Inbuilt table lookups include the Item, Item Attribute, Customer, Vendor, BOM, Routing, and Quality Measure. These references depend on the source configuration used when creating the test.

Other tables can be referenced with the expression “[Lookup(TableName;FieldName;Field1=Value1)]”. See the _[Look up Specifications from Another Table when Creating Quality Inspection Tests](/kb/quality-inspector/look-up-specifications-from-another-table-when-creating-quality-inspection-tests/)_ page for more examples.

| **Lookup** | **Expression** | **Example** |
| --- | --- | --- |
| Item | [Item:FieldName] | [Item:No.] |
| Item Attribute | [ATTRIBUTE:AttributeName] | [ATTRIBUTE:Colour] |
| Customer | [Customer:FieldName] | [Customer:Name] |
| Vendor | [Vendor:FieldName] | [Vendor:City] |
| BOM | [BOM:FieldName] | [BOM:Description] |
| Routing | [Routing:FieldName] | [Routing:Status] |
| Quality Measure | [Measure:FieldName] | [Measure:Min. Value] |
| Any other table | [Lookup(TableName;FieldName;Field1=Value1)] | [Lookup(Example Specification;Target Salt Pct.;Version=[Item:Example Specification Version])] |

### Additional expressions

| **Method** | **Expression** | **Example** |
| --- | --- | --- |
| Text Replacement | [REPLACE(SearchThisText;ReplaceThis;WithThis)] | The expression [Replace(Cat;C;H)] would result in “Hat”. |
| Whole-Value Classification | [CLASSIFY(IfThisText;MatchesThisText;ThenThisValue)] | A field called “[MyChoice]” has the possible values of A and B. When the value is A, we want 3, and when the value is B, we want 456. [Classify([MyChoice];A;3)][Classify([MyChoice];B;456)] |
| Text Extraction | [COPYSTR(OriginalText;Position;Length)] | Extract “123” from the text “ABC123DEF” [Copystr(ABC123DEF;4;3)] |

### Expressions with more than two values

There are two options to calculate an expression with more than two values:

- Nest expressions
- Use the base calculation

#### Nest expressions

One option to calculate an expression with more than two values is to nest expressions. For example, while the expression MIN(Value1;Value2) evaluates between two values, the expression MIN(Value1;MIN(Value2;Value3)) evaluates the smallest of three values.

#### Use the base calculation

Another option is to use the base calculation. For example, the “AVERAGE(Value1;Value2)” expression evaluates between two values, and the expression “(Value1+Value2+Value3)/3” evaluates the average between the three values.

### Example expressions

#### Pass Condition: Dependence on another test field (container type)

If the container is of type “A”, then the measured value must be 12.9; if the container is of type “B”, then the measured value must be 15.0 to pass.[CLASSIFY([CONTYPE];A;12.9)][CLASSIFY([CONTYPE];B;15.0)]

#### Pass Condition: Dependence on item attribute

If the item height is less than 6, the pass condition is 8; otherwise, it is the height +5.

{IF(LT([ATTRIBUTE:Height];6);8;[ATTRIBUTE:Height]+5)}

### Pass Condition: Ensure total weight is +/- 5% of expected value using custom BOM weight field and test source quantity

Weight \* Quantity \* 95% < Total Weight < Weight \* Quantity \* 105%

..

{[BOM:CustomWeight]\*[Source Quantity (Base)]\*0.95}..{[BOM:CustomWeight]\*[Source Quantity (Base)]\*1.05}

### Calculate true position using custom item nominal position fields

{2\*SQRT(POW([MeasuredValueX]-[Item:CustomNominalX];2)+POW([MeasuredValueY]-[Item:CustomNominalY];2))}

### Ball Rebound / Energy Restitution Calculation

([ReboundHeight] / [DropHeight]) \* 100

### Moisture Content and Temperature Compensation

In this example, the base calibration value would represent 20c, and the temperature correction coefficient would be 0.05.  If we presume 20 is the standard reference temperature that your tool is calibrated to, you could use 20 as a number directly or alternatively you could always use a variable or a lookup to the base calibration value.

[RawMoistureMeterReading] - ( ([AmbientTemperature]-20) \* 0.05) or [RawMoistureMeterReading] - ( ([AmbientTemperature]-[BaselineTemperature]] \* [CorrectionCoef])

### Multi-point average, such as a Surface Friction or Slip Resistance Index Average

In this example there would be four specific test points that would be used to calculate traction coefficients.

([TestPoint1] + [TestPoint2] + [TestPoint3] + [TestPoint4]) / 4 or AVG([TestPoint1];[TestPoint2];[TestPoint3];[TestPoint4])
