You are here: Commands > Group > Conditional Groups

Conditional Groups

Conditional groups execute commands based on whether a condition is true or false. For example, the following Group command is executed only on records with a ProdCls field whose value is less than 5:

GROUP IF ProdCls < "05"¿

COUNT¿

HISTOGRAM ON QtyOH MINIMUM 0 MAXIMUM 100 INTERVALS 10¿

CLASSIFY ON Loc ACCUMULATE QtyOH¿

END¿

Records that do not meet the test condition are ignored unless you include an Else statement.

Any number of commands can follow an Else statement. In the following example, all records that do not meet the condition are processed by having their QtyOH field totaled.

GROUP IF ProdCls < "05"¿

COUNT¿

HISTOGRAM ON QtyOH MINIMUM 0 MAXIMUM 100 INTERVALS 10¿

CLASSIFY ON Loc ACCUMULATE QtyOH¿

ELSE¿

TOTAL QtyOH¿

END¿

You can include multiple Else/If statements within a group, as long as each intermediate Else/If statement contains a unique test. Only the final Else may have no condition specified. In the following example, the Else/If statements produce four possible alternate totals:

GROUP IF ProdCls < "05"¿

COUNT¿

HISTOGRAM ON QtyOH MINIMUM 0 MAXIMUM 100 INTERVALS 10¿

CLASSIFY ON Loc ACCUMULATE QtyOH¿

ELSE IF ProdCls = "05"¿

TOTAL QtyOH¿

ELSE IF ProdCls = "06"¿

TOTAL QtyOH¿

ELSE IF ProdCls = "07"¿

TOTAL QtyOH¿

ELSE¿

TOTAL QtyOH¿

END¿

The logic flow is sequential from top to bottom as in a standard IF/THEN/ELSE test.