...
Excerpt | ||
---|---|---|
| ||
sumIf(list) |
...
Returns the sum of a set of numbers on the condition that all the values are either null or valid Numbers |
. |
Function: sumIf()
Returns the sum of a set of numbers based on a series of corresponding true/false conditions.
Syntax
sumIf(listnumberList, conditionList)
Argument | Type | Description |
---|---|---|
listnumberList | Number Array | An Array containing a list of numeric values |
conditionList | Condition List | AnĀ Array containing a list of PhixFlow expressions that must evaluate to true or false |
Examples
Example 1
Code Block |
---|
sumIf([ |
...
1, |
...
1, |
...
1, |
...
Returns the sum of the numbers in list above i.e. 10 + 2 + 3 + 3.3 = 18.3
sumIf([10, 2, , 3.3])
Returns the sum of the numbers in list above and will ignore empty values i.e. 10 + 2 + 3.3 = 15.3
sumIf([10, 2, a, 3.3])
Returns a type error as the value 'a' is not a numeric value
sumIf(in.invoiceAmount)
...
1], [1,0,1,0]) |
returns 2.
Example 2
Code Block |
---|
sumIf(in.Total, in.Include) |
If this is applied to the 3 records from the in pipe
Code Block |
---|
{
{Total = 32, Include = 1},
{Total = 20, Include = 0},
{Total = 15, Include = 1},
} |
returns 47.