Minimum Origin Version Required: 2019 SR0
This function is used to evaluate a value to multiple conditions, and return the corresponding value when the first TRUE condition is met. Up to 40 conditions can be supported. It is the equivalent of nested If function but easier to read, especially when there are many conditions.
Note: to set a default result, you will need to use 1 instead of TRUE for LabTalk compability. For example,
Ifs(A>0.5,"Large",A<0.3,"Small",1,"Other")$
it means, if values in col(A) is larger than 0.5, return Large, if smaller than 0.3, returns Small, the rest in between will return Other.
double Ifs(string con1, double d1[, string con2, double d2,]...[,string con40,double d40])
string Ifs(string con1, string str1$[, string con2, string str2$]...[,string con40, string str40$])$
conn
dn, strn
Return
Ex1
IF value in col(A) is larger than 0.5, returns Large, smaller than 0.3, returns Small, otherwise returns Median.
Ifs(A>0.5,"Large",A<0.3,"Small",1,"Median")$
Ex2
newbook; patternT irng:=col(A) text:="Apple Boy Cat" mode:=random; csetvalue col:=col(B) formula:="ifs(A$=="Apple","Fruit",A$=="Boy","People",A$=="Cat","Animal")$";