Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.



Excerpt
hiddentrue

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 on the condition that all the values are either null or valid Numbers, a type error will be thrown if any of the values are non-numericbased on a series of corresponding true/false conditions.

Syntax

sumIf(listnumberList, conditionList)

ArgumentTypeDescription
listnumberListNumber ArrayAn Array containing a list of numeric values
conditionListCondition ListAnĀ 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 (the following is pseudo-code used to represent a recordset):

Code Block
{
	{Total = 32, Include = 1},
	{Total = 20, Include = 0},
	{Total = 15, Include = 1},
}

returns 47.

See Also