-
Notifications
You must be signed in to change notification settings - Fork 5
Expressions
chrisala edited this page May 24, 2019
·
4 revisions
Expressions can be used in various places in the form metadata file.
They are implemented using the expression evaluator library: https://github.com/silentmatt/expr-eval
Variables in expressions are bound to the data model and the supported operators are described in the documentation of the library.
e.g
{
"dataType":"number",
"name":"example",
"computed": {
"expression":"value1+value2*3"
}
}
In addition to the library supported operators, there are a few functions that work on list (array) data types. These are: sum, count, any, none, all.
Each of these functions takes an array as the first argument and a string expression as the second. The expression will be evaluated against each element of the array.
e.g.
{
"dataType":"list",
"name":"listData",
"columns":[...]
},
{
"dataType":"number",
"name":"example",
"computed":{
"expression":"sum(listData, \"value1+value2\")"
}
}
nb when using string literals in expressions, use double quotes not single quotes.