Minimum Origin Version Required: 2019 SR0

This function is used to evaluate a condition and return certain values depending on whether the comparison is True or False. The values can be text and numeric. To compare a set of values by multiple conditions, use nested IF functions.

**Note**: IF function can only be used in **Set Column Values** dialog or Cell Formula. It cannot be used in general Labtalk script.

double If(string con, double val_true[, double val_false])

string If(string con, string val_true$[, string val_false$])$

**con**

- The condition expression comparing a value to another value.

**val_true**

- the returned value when the condition is True. It can be numeric or text. If text value, must be enclosed in double quotes ("").

**val_false**

- the returned value when the condition is False. It can be numeric or text. If text value, must be enclosed in double quotes ("").

Return the specified values depending on the result of comparison.

**Ex1**

IF value in col(A) is larger than col(B), returns *1*, otherwise returns *0*.

- Create a new Workbook. Fill col(A) and col(B) with some random number.
- Add col(C). Right click on col(C) and select
**Set Column Values**from context menu. In the Set Values**dialog enter formula**if(A>B,1,0)

**Ex2**

IF value in col(A) is larger than *0.5*, returns *Good*, otherwise returns *Bad*.

- Create a new Workbook. Fill col(A) with some random number.
- Double click in the first cell of col(B) and enter formula
=if(A1>0.5,"Good","Bad")$

- Escape the in-place edit mode. Select cell B1 and carefully move your mouse to the bottom-right edge of B1 until the cursor become "+". Hold down the left mouse button and drag down to the last cell of col(B) to auto-fill those cells.

**Ex3**

IF value in col(A) is larger than *0.5*, returns *Large*, smaller than *0.3*, returns *Small*, otherwise returns *Median*.

- Create a new Workbook. Fill col(A) with some random number.
- Right click on col(B) and select
**Set Column Values**from context menu. In the Set Values**dialog enter formula**If(A>0.5,"Large",If(A<0.3,"Small","Median")$)$

**Ex4**

- Create a new Workbook. Select columns A and B, right click and
**Fill Column with: Arbitrary set of Text&Numeric values**. In**Text to Repeat**, enter "Larry Moe Curly" (without the " " marks). Set**Mode**=**Random**and click**OK**. Columns A and B are filled with text values. - Add a third column to the worksheet and in the
**F(x)=**cell of the third column, enter the following:if(A$==B$,1,0)

The column will be filled with "0" where col(A)[i] does*not*match col(B)[i] and "1" where col(A)[i]*does*match col(B)[i]. - Add a fourth column to the sheet and in the
**F(x)=**cell enterif(A$==B$, "Stooge Match!", " ")

Where strings in col(A)[i] and col(B)[i] match, the cell is filled with "Stooge Match!". Where there is no match, the cell is left blank.