Aggregate Operator

Overview

A static image displaying the Data Workflow component's Aggregate Operator icon and information window.

The Aggregate operator lets you perform one of five operations on your data set:

  • Sum By: Adds all numbers in a given range.

  • Count By: Counts the number of values in a given range that contain numeric values.

  • Mean By: Calculates the average of values in a given range.

  • Max By: Finds the highest value in a given range.

  • Min By: Finds the lowest value in a given range.

In this article, we'll focus on the Sum By operation. Let's say you have a data table containing various dog names and their weight in pounds. Then, you want to sum all the weights and output the total. The Aggregate operator can sum every weight in that column and output the total.

How you sum values is based on JavaScript JavaScript is an object-oriented computer programming language. It is most-commonly used for interactive effects in the browser.. If you input a single value of null, it returns null and an error message in the DevTools Console The DevTools Console helps you securely store, build, test, and deploy your software.. If you input two values of null, the operator sums them and returns a value of 0.

Similar Data Workflow Operators

Here are some of the operators you can compare the Aggregate operator with:

About the Info Window

Here's a breakdown of each setting in the Info window:

Info

Label

Sets the label for your operator, displaying below the operator on your Data Workflow canvas.

This field is optional, but set a label if you use more than one of the same operator type. A label helps you identify your operators without opening any Info windows.

Aggregation Type

Sets the operation to perform on your data. You have the following options:

  • Sum By: Evaluates the value in the Value Key field and adds all number values for a range.

  • Count By: Evaluates the value in the Value Key field and counts the number of cells containing number values.

  • Mean By: Evaluates the value in the Value Key field and calculates the average.

  • Max By: Evaluates the value in the Value Key field and determines the highest value.

  • Min By: Evaluates the value in the Value Key field and determines the lowest value.

You can only choose one operation for each operator. But you can have as many Aggregate operators in your Data Workflow as you need. Use labels to organize each operator.

Join Group Keys

When set to YES, the operator creates a new column that joins the values of your individual Group Keys.

For example, let's say you're working with the dog information data with columns of age and breed. Selecting YES returns a column called age-breed, and your result displays as 12-chow.

Group Key

This field lets you separate your selected operation into categories. For example, if you want to calculate the mean of dog weight in your data table for each dog breed. You'll enter breed in the Group Key field. That way, the operator treats each unique value in the breed column as its own group. Your Data Workflow then returns a mean value for each group.

When entering more than one Group Key, separate each using a comma.

To see a Group Key in action, view our Aggregate Operator: Count By Use Casearticle.

Value Key

This field lets you enter a data table column header to perform an operation on. For example, you have a column header of cost and you want to calculate the sum of all values in that column. You'll enter cost in the Value Key field. Or, maybe you are using the operator to find the highest value in a column with a header of age. Then, you'll enter age into this field.

The Value Key field is case-sensitive and must match your column header exactly.

Adding a Sum By Aggregate Operator

In this example, you'll configure a Data Table component to store various dog names and their weights in pounds. Then, you'll configure a Data Workflow that sums all the weights.

This use case focuses on the Sum By function of the Aggregate operator. You can find other use cases in the Resources section of this article.

These instructions assume you have a new module open and saved with a title.

Configure the Data Table Component

First, you'll configure a Data Table component to store your data and input it into a Data Workflow component.

1. In the Module Builder, drag and drop a Dropdown Component IconData Table component onto your canvas.
2. In the Property ID A Property ID is the unique field ID used by Unqork to track and link components in your module. field, enter dtDogs.
3. In the data table, enter the following:
 

A

B

1

name

weight

2

Ivy

60

3

Lucy

80

4

Wally

20

5

Nacho

10

6

Thor

50

7

Holly

100

A static image displaying the list of dog names and their weights

4. Click Save Component.

Configure the Data Workflow Component

Next, you'll configure a Data Workflow component to retrieve the stored data and use an Aggregate operator to calculate the sum of your weight column. Then, you'll output the summed value and store it in a Hidden component.

1. Drag and drop a Data Workflow onto your canvas, placing it below the Dropdown Component IconData Table component.
2. In the Property ID A Property ID is the unique field ID used by Unqork to track and link components in your module. and Canvas Label Text Canvas Label Text indicates the purpose of the corresponding field or component. For non-input components, the Canvas Label Text isn't end-user facing, and only appears in the . fields, enter dwfWeight.

Configure the Input Operator

1. Drag and drop an Input operator onto your Data Workflow canvas.
2. Configure the operator's Info window as follows:
Info

Category

Input

Component

dtDogs

Required

Yes

Source

Default

Configure the Aggregate Operator

1. Drag and drop an Aggregate operator onto your Data Workflow canvas.
2. Configure the operator's Info window as follows:
Info

Category

Aggregate By

Label

Total Weight

Aggregation Type

Sum By

Join Group Keys

No

Group Key

 

Value Key

weight

3. Connect the output port (right) of the Input operator to the upper input port (left) of the Aggregate operator.

Configure the Output Operator

1. Drag and drop an Output operator onto your Data Workflow canvas.
2. Configure the operator's Info window as follows:
Info

Category

Output

Component

sumWeight

Action

value

3. Connect the output port (right) of the Aggregate operator to the input port (left) of the Output operator.
4. Click Save Component.

Here's how the completed Data Workflow looks:

A static image displaying the Data Workflow component's completed configuration in the configuration window.

Configure the Hidden Component

Now, you'll configure a Hidden component to store the summed value.

1. Drag and drop a Hidden component onto the canvas, placing it below your Data Workflow component.
2. In the Property ID A Property ID is the unique field ID used by Unqork to track and link components in your module. and Label Text Label Text conveys what the input component is and what information it displays. Enter the purpose of the corresponding component or field. fields, enter sumWeight.
3. Click Save Component.

Configure the Button Component

Lastly, add a Button component to trigger the Data Workflow and calculate the summed weight.

1. Drag and drop a Button component Icon Button component onto your canvas, placing it between your Dropdown Component IconData Table and Data Workflow components.
2. In the Property ID A Property ID is the unique field ID used by Unqork to track and link components in your module. field, enter btnTotalWeight.
3. In the Label Text Label Text conveys what the input component is and what information it displays. Enter the purpose of the corresponding component or field. field, enter Find Total Weight.
4. From the Action Type drop-down, select Event.
5. From the On Click drop-down, select dwfWeight.

A static image displaying the Button component's completed configuration in the configuration window.

6. Click Save Component.
7. Save your module.

Here's how the completed use case looks in the Module Builder:

A static image displaying the completed configuration in the Module Builder.

Preview your module in Express View Express View is how your end-user views your application. Express View also lets you preview your applications to test your configuration and view the styling. This is also the view your end-users will see when interacting with your application. After configuring a module, click Preview in the Module Builder to interact with the module in Express View. and open the DevTools Console The DevTools Console helps you securely store, build, test, and deploy your software.. Click the button and run the Angular command The Angular command, or data command, is a tool that displays submission data in a browser's developer console. In Express View, enter the following command in the devtool console: angular.element('.unqorkio-form').scope().submission. Expand the data and to view the total weight stored in the sumWeightHidden component.

A static image displaying the data returned in the DevTools Console in Express View.

Overview

A static image displaying the Classic Dessigner's- Data Workflow component's Aggregate Operator icon and information window.

The Aggregate operator lets you perform one of five operations on your data set:

  • Sum By: Adds all numbers in a given range.

  • Count By: Counts the number of values in a given range that contain numeric values.

  • Mean By: Calculates the average of values in a given range.

  • Max By: Finds the highest value in a given range.

  • Min By: Finds the lowest value in a given range.

In this article, we'll focus on the Sum By operation. Let's say you have a data table containing various dog names and their weight in pounds. Then, you want to sum all the weights and output the total. The Aggregate operator can sum every weight in that column and output the total.

How you sum values is based on JavaScript JavaScript is an object-oriented computer programming language. It is most-commonly used for interactive effects in the browser.. If you input a single value of null, it returns null and an error message in the DevTools Console The DevTools Console helps you securely store, build, test, and deploy your software.. If you input two values of null, the operator sums them and returns a value of 0.

Similar Data Workflow Operators

Here are some of the operators you can compare the Aggregate operator with:

About the Info Window

Here's a breakdown of each setting in the Info window:

Setting

Description

Label

Sets the label for your operator, displaying below the operator on your Data Workflow canvas.

This field is optional, but set a label if you use more than one of the same operator type. A label helps you identify your operators without opening any Info windows.

Aggregation Type

Sets the operation to perform on your data. You have the following options:

  • Sum By: Evaluates the value in the Value Key field and adds all number values for a range.

  • Count By: Evaluates the value in the Value Key field and counts the number of cells containing number values.

  • Mean By: Evaluates the value in the Value Key field and calculates the average.

  • Max By: Evaluates the value in the Value Key field and determines the highest value.

  • Min By: Evaluates the value in the Value Key field and determines the lowest value.

You can only choose one operation for each operator. But you can have as many Aggregate operators in your Data Workflow as you need. Use labels to organize each operator.

Join Group Keys

When set to YES, the operator creates a new column that joins the values of your individual Group Keys.

For example, let's say you're working with the dog information data with columns of age and breed. Selecting YES returns a column called age-breed, and your result displays as 12-chow.

Group Key

This field lets you separate your selected operation into categories. For example, if you want to calculate the mean of dog weight in your data table for each dog breed. You'll enter breed in the Group Key field. That way, the operator treats each unique value in the breed column as its own group. Your Data Workflow then returns a mean value for each group.

When entering more than one Group Key, separate each using a comma.

To see a Group Key in action, view our Aggregate Operator: Count By Use Casearticle.

Value Key

This field lets you enter a data table column header to perform an operation on it. For example, you have a column header of cost and you want to calculate the sum of all values in that column. You'll enter cost in the Value Key field. Or, maybe you are using the operator to find the highest value in a column with a header of age. Then, you'll enter age into this field.

The Value Key field is case-sensitive and must match your column header exactly.

Adding a Sum By Aggregate Operator

In this example, you'll configure a Data Table component to store various dog names and their weights in pounds. Then, you'll configure a Data Workflow that sums all the weights.

This use case focuses on the Sum By function of the Aggregate operator. You can find other use cases in the Resources section of this article.

These instructions assume you have a new module open and saved with a title.

Configure the Data Table Component

First, you'll configure a Data Table component to store your data and input it into a Data Workflow component.

1. In the Module Builder, drag and drop a Dropdown Component IconData Table onto your canvas.
2. In the Property ID A Property ID is the unique field ID used by Unqork to track and link components in your module. and Canvas Label Text Canvas Label Text indicates the purpose of the corresponding field or component. For non-input components, the Canvas Label Text isn't end-user facing, and only appears in the . fields, enter dtDogs.
3. To the left of the component's configuration window, click Data.
4. In the data table, enter the following:

A

B

name

weight

Ivy

60

Lucy

80

Wally

20

Nacho

10

Thor

50

Holly

100

5. Click Save & Close.

A static image displaying the Data Table component's completed configuration in the configuration window.

Configure the Data Workflow Component

Next, you'll configure a Data Workflow component to retrieve the stored data and use an Aggregate operator to calculate the sum of your weight column. Then, you'll output the summed value and store it in a Hidden component.

1. Drag and drop a Data Workflow onto your canvas, placing it below the Dropdown Component IconData Table component.
2. In the Canvas Label Text Canvas Label Text indicates the purpose of the corresponding field or component. For non-input components, the Canvas Label Text isn't end-user facing, and only appears in the . and Property ID A Property ID is the unique field ID used by Unqork to track and link components in your module. fields, enter dwfWeight.

Configure the Input Operator

1. Drag and drop an Input operator onto your Data Workflow canvas.
2. Configure the operator's Info window as follows:

Setting

Value

Category

Input

Component

dtDogs

Required

Yes

Source

Default

Configure the Aggregate Operator

1. Drag and drop an Aggregate operator onto your Data Workflow canvas.
2. Configure the operator's Info window as follows:

Setting

Value

Category

Aggregate By

Label

Total Weight

Aggregation Type

Sum By

Join Group Keys

No

Group Key

 

Value Key

weight

3. Connect the output port (right) of the Input operator to the input port (left) of the Aggregate operator.

Configure the Output Operator

1. Drag and drop an Output operator onto your Data Workflow canvas.
2. Configure the operator's Info window as follows:

Setting

Value

Category

Output

Component

sumWeight

Action

value

3. Connect the output port (right) of the Aggregate operator to the input port (left) of the Output operator.
4. Click Save.

Here's how the completed Data Workflow looks:

A static image displaying the Data Workflow component's completed configuration in the configuration window.

Configure the Hidden Component

Lastly, you'll configure a Hidden component to store the summed value.

1. Drag and drop a Hidden component onto the canvas, placing it below your Data Workflow component.
2. In the Property ID A Property ID is the unique field ID used by Unqork to track and link components in your module. and Canvas Label Text Canvas Label Text indicates the purpose of the corresponding field or component. For non-input components, the Canvas Label Text isn't end-user facing, and only appears in the . fields, enter sumWeight.
3. Click Save & Close.

Configure the Button Component

Now, add a Button component to start the whole operation. Clicking the button fires your Data Workflow which calculates the summed weight.

1. Drag and drop a Button component Icon Button component onto your canvas, placing it between your Dropdown Component IconData Table and Data Workflow components.
2. In the Property ID A Property ID is the unique field ID used by Unqork to track and link components in your module. field, enter btnTotalWeight.
3. In the Label Text Label Text conveys what the input component is and what information it displays. Enter the purpose of the corresponding component or field. field, enter Find Total Weight.
4. To the left of the component's configuration window, click Actions Icon Actions.
5. Set the Action Type as Event.
6. From the On Click drop-down, select dwfWeight.

A static image displaying the Button component's completed configuration in the configuration window.

7. Click Save & Close.
8. Save your module.

Below is the completed configuration in the Module Builder:

A static image displaying the completed configuration in the Module Builder.

Preview your module in Express View Express View is how your end-user views your application. Express View also lets you preview your applications to test your configuration and view the styling. This is also the view your end-users will see when interacting with your application. After configuring a module, click Preview in the Module Builder to interact with the module in Express View. and open the DevTools Console The DevTools Console helps you securely store, build, test, and deploy your software.. Click the button and run the Angular command The Angular command, or data command, is a tool that displays submission data in a browser's developer console. In Express View, enter the following command in the devtool console: angular.element('.unqorkio-form').scope().submission. Expand the data and you'll see the total weight stored in the sumWeightHidden component.

A static image displaying the data returned in the DevTools Console in Express View.