Aggregate Operator
Overview
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
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:
-
Append operator: Combines strings A string is an object that represents a sequence of characters. Strings typically hold data represented in text form. or arrays An array is a type of object that stores one or more data types. Data types supported in arrays include numbers, strings, and objects. together. When appending strings, the operator performs a concatenation on the values. When appending arrays, it combines the arrays into one.
-
Extend operator: Combines two objects An object is a type of data structure that represents a single, self-contained entity that acts as a container for the characteristics of that entity. into a single object. The Extend operator is typically used with Group Input operators to create objects with more than six fields.
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:
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 ![]() |
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 |
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 ![]() |
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:
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. |
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 ![]() ![]() |
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. |
6. | Click Save Component. |
7. | Save your module. |
Here's how the completed use case looks 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.
Overview
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
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:
-
Append operator: Combines strings A string is an object that represents a sequence of characters. Strings typically hold data represented in text form. or arrays An array is a type of object that stores one or more data types. Data types supported in arrays include numbers, strings, and objects. together. When appending strings, the operator performs a concatenation on the values. When appending arrays, it combines the arrays into one.
-
Extend operator: Combines two objects An object is a type of data structure that represents a single, self-contained entity that acts as a container for the characteristics of that entity. into a single object. The Extend operator is typically used with Group Input operators to create objects with more than six fields.
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:
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.
|
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 ![]() |
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:
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. |
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 ![]() ![]() |
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 ![]() |
5. | Set the Action Type as Event. |
6. | From the On Click drop-down, select dwfWeight. |
7. | Click Save & Close. |
8. | Save your module. |
Below is 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.
Resources