3.5.12.7 LetLet-func
Description
Minimum Origin Version Required: 2021
Similar to MS Excel's LET() function. Assign values to variables, for up to 39 variable-value pairs, for use in expression. Optional $ is used is used when returning strings.
Syntax
LET(name1,value1[,name2,value2,]...[,name39, value39], expression)[$]
Parameters
name1 ... 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
Return
Return the result of expression.
Example
// 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)";
// 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$)";
// support vector
let(v, movslope(A,B,3), idx(abs(v)>1))
See Also
|