Skip to main content
Skip to main content

sumArray

Description

The Array combinator can be applied to the sum function to calculate the sum of all elements in an array, using the sumArray aggregate combinator function.

The sumArray function is useful when you need to calculate the total sum of all elements across multiple arrays in a dataset.

Example Usage

In this example, we'll use a sample dataset of daily sales across different product categories to demonstrate how sumArray works. We'll calculate the total sales across all categories for each day.

The sumArray function will sum up all elements in each category_sales array. For example, on '2024-01-01', it sums 100 + 200 + 150 = 450. This is equivalent to using sum(arraySum(category_sales)), where arraySum first sums the elements within each array, and then sum aggregates those results.

See also