| 3.5.12.7 LetLet-func 
 DescriptionMinimum Origin Version Required: 2021 Assign values to variables (up to 39 variable-value pairs) and calculate values by using expression. Optional $ is used is used when returning strings. 
 Similar to MS Excel's LET() function. 
 SyntaxLET(name1,value1[,name2,value2,]...[,name39, value39], expression)[$] Parametersname1 ... name39
  the variable name paired with values var1 through var39
 value1 ... value39
  the value(s) paired with name1 through name39 
 expression
  expression to be evaluated using value1 ... value39
 $
  use $ when returning a string
 ReturnReturn the result of expression.
 ExampleExample 1
 // expression is a formula
newbook; //start a new workbook
wks.nCols = 3; //set number of columns to 3
patternT irng:=1 text:="A B C" mode:=random; //fill 1st column with random A, B and C
patternT irng:=2 text:="A B C" mode:=random; //fill 2nd column with random A, B and C
//set column C value as 500 if column A&B have same value, otherwise set C as missing value
//The LET() function assigns if() function result to t and calculate t*500
csetvalue col:=col(C) formula:="LET(t,if(A$==B$,1,0/0),t*500)"; Example 2
 // expression is a string
newbook; //start a new workbook
wks.nCols = 3; //set number of columns to 3
patternT irng:=1 text:="Matty Sammy Domingo Nancy Wooly"  mode:=random; //fill 1st col w/ random names
patternT irng:=2 text:="Joseph Hattie Robert Samudio Bully"  mode:=random; //fill 2nd col w/ random names
// use LET() to concatenate strings with literal char "-"
csetvalue col:=col(C) formula:="LET(first,left(A,5),last,left(B,5), first$+ "-" + last$)"; Example 3
 // support vector
let(v, movslope(A,B,3), idx(abs(v)>1)) Example 4
 newbook;
wks.ncols = 3;
col(A) = uniform(32);
col(B) = uniform(32);
csetvalue col:=col(C) formula:="let(tt, B/A, tt>0.5?"Good":"Poor")"; See Also |