Conditional Functions

Version:
2019.3
Last modified: October 29, 2019

A conditional function performs an action or calculation based on a test of data using an IF statement. Use a conditional function to provide a TRUE or FALSE result to highlight or filter out data based on specific criteria. Conditional functions can be used with any data type. 

Consider each conditional function before writing your test. Some conditional functions are better suited to specific use cases.

IF c THEN t ELSE f ENDIF: IF condition THEN true ELSE false ENDIF

Example

IF [Class]==1 THEN "Gold" ELSE "Other" ENDIF

Class Result
1 Gold
2 Other
1 Gold
3 Other

IF c THEN t ELSEIF c2 THEN t2 ELSE f ENDIF: IF condition THEN true ELSEIF condition2 THEN true2 ELSE false ENDIF

Multiple ELSEIF statements can be included.

Example

IF [Class]==1 THEN "Gold" ELSEIF [Class]==2 THEN "Silver" ELSE "Other" ENDIF

Class Result
1 Gold
2 Silver
1 Gold
3 Other

IIF(bool,x,y): If ([bool] is true) return (x), else return (y)

Example

IIF([CUSTOMER], "Send flyer", "Send documentation")

If the [CUSTOMER] field value is TRUE, then it returns Send flyer.

If the [CUSTOMER] field value is FALSE, then it returns Send documentation.

Switch(Value,Default,Case1,Result1,...,CaseN,ResultN): Compares a value against a list of cases and returns the corresponding result.

Example

Switch([Class], Null(), "Gold",1,"Silver",2,"Bronze", 3,"Tin", 4, "Aluminum",5)

Result Class
5 Aluminum
2 Silver
1 Gold
3 Bronze
4 Tin
2 Silver
1 Gold
Null Other
Was This Helpful?

Need something else? Visit the Alteryx Community or contact support.