sumif - Sumif Spreadsheet Function for an Array
Implements a sumif function similar to GSheet and Excel functions. Sum elements of an array by a given criterion.
data
array
Array of objects with at least two properties e.g. [{name,score}] each.
Minimum: 1
Example:
[
{
"name": "Alice",
"score": 1
},
{
"name": "Bob",
"score": 2
},
{
"name": "Charlie",
"score": 4
},
{
"name": "Dave",
"score": 8
},
{
"name": "Bob",
"score": 16.5
}
]
queryField
string
Name of the field in data to look for critera. Case sensitive
Example:
name
operator
string
Comparison operator. Defaults to eq
Possible values are: eq, gt, ge, lt, le, ne
Example:
eq
criteria
string
Criteria to look for must be number or string
Example:
Bob
sumField
string
Name of the field in data to sum up. Case sensitive.
Example:
score
ignoreCase
boolean
Sets case sensitivity for criteria operation. Defaults to true