Formula - compare text

 

Expression for comparing two pieces of text in a formula

 

Using text comparisons (string comparisons) in product variables

 

("@TOP@"="WHITE")

 

In this example the product variable (@ variable) TOP is compared to the fixed string WHITE. The contents of TOP depend on the answer entered for the TOP variable. The formula evaluates to 1 if the comparison is true and 0 if the comparison is false.

 

The comparison ignores case so that White is the same as WHITE.

Do not use a quotation mark in a string

Spaces are evaluated so that WHITE M is different to WHITEM

Keep the comparisons in brackets so the formula is easier to read

 

A simple example of the use of string comparison is a custom product where there is a choice of material for some parts.

 

For example, use a single product definition to deal with a custom unit that is made with 2 BROWN doors if the top is BEIGE or 2 GREEN doors if the top OFFWHITE

 

 

 

Code     Description     X Width    Y Height   Z Depth

DESK/S1  Exec. Unit      600          400          500

Memo:

Code       Qty                      Material

DOOR-1   =2*("@TOP@"="OFFWHITE")     GREEN

DOOR-2   =2*("@TOP@"="BEIGE")        BROWN

TOP      1                           @TOP@

BACK     1                           MDF15

 

In this example the doors are represented by the parts DOOR-1 and DOOR-2.

 

If the TOP colour is chosen as OFFWHITE the formula in the QTY box evaluates to 2 for DOOR-1 and evaluates to 0 for DOOR-2. So 2 GREEN doors are produced and 0 BEIGE doors.

 

2 BROWN doors are produced when the TOP colour is chosen as BEIGE

 

DOOR-1   =2*("@TOP@"="OFFWHITE")     GREEN

DOOR-2   =2*("@TOP@"="BEIGE")        BROWN

 

Use the symbol = or == for EQUAL TO

Use the symbol != or <> for NOT EQUAL TO

 

=2*("@TOP@"!= "RED")

 

Comparing blank strings in formula - compare a string to a blank (or empty string). This can be useful, for example, to test that a variable is not blank.

 

("@COLOUR@"!="")

 

That is, is the variable colour not equal to blank. The quotation symbols "" stand for blank. This is a simple way of establishing whether a variable has been answered or not.

 

 

Notes

 

The symbol '<>' can also be used for 'not equal to'.

 

 

See also