Overview
The Aggregate operator is used to count the number of entries in a data set. You can also use the operator’s Group Key field, which lets you to group the results into categories based on values from the original data.
For example, consider a Data Table component that stores the details of several dogs and their favorite foods. You'll configure a Data Workflow component to count how many dogs have the same favorite food. In this example , each type of food displays as a separate category using the Group Key field.
Configuration
Configure the Data Table Component
First, you'll add a Data Table component to store a list of dogs and favorite foods that your Data Workflow component can retrieve.
In the Module Builder, drag and drop a Data Table component onto your canvas.
In the Property ID field, enter
dtDogs
.In the data table, enter the following:
A
B
1
name
favoriteFood
2
Ivy
Peanut Butter
3
Lucy
Beef Jerky
4
Wally
Peanut Butter
5
Nacho
Peanut Butter
6
Thor
Salmon
7
Holly
All Foods
Click Save Component.
Configure the Data Workflow Component
Next, you'll add your Data Workflow component and bring your data into the Data Workflow using an Input operator. Then, you'll add an Aggregate operator to count how many dogs have the same favorite food. But to get an accurate count, you must count the names associated with each favorite food. So, you'll set the Aggregate operator to use the Value Key of name and Group Key of favoriteFood. Lastly, you'll view the result using a Console operator and the DevTools Console.
Drag and drop a Data Workflow component onto your canvas, placing it below your dtDogs Data Table component.
In the Property ID and Canvas Label Text fields, enter
dwfFavoriteFood
.
Configure the Input Operator
Drag and drop an Input operator onto your Data Workflow canvas.
Configure the operator's Info window as follows:
Info
Category
Input
Component
dtDogs
Required
Yes
Source
Default
Configure the Aggregate Operator
Drag and drop an Aggregate operator onto your Data Workflow canvas.
Configure the operator's Info window as follows:
Info
Setting
Value
Category
Aggregate By
Label
Favorite Food Counts
Aggregation Type
Count By
Join Group Keys
Yes
Group Key
favoriteFood
Value Key
name
Connect the output port (right) of the dtDogs Input operator to the input port (left) of the Favorite Food Counts Aggregate operator.
Configure the Console Operator
Drag and drop a Console operator onto your Data Workflow canvas.
Configure the operator's Info window as follows:
Info
Category
Console
Label
How many dogs have the same favorite food?
Connect the output port (right) of the Favorite Food Counts Aggregate operator to the input port (left) of the How many dogs have the same food? Console operator.
Click Save Component.
Configure the Button Component
Now, you'll add a Button component to trigger the Data Workflow. Clicking the button executes the Data Workflow and counts the number of dogs who have the same favorite food.
Drag and drop a
Button component onto your canvas, placing it below the Data Workflow component.
In the Property ID, enter btnFavoriteFood.
In the Label Text, enter
Count Favorite Foods
.From the Action Type drop-down, select Event.
From the On Click drop-down, select dwfFavoriteFood.
Click Save Component.
Save your module.
Here's how your module looks in the Module Builder:
Preview your module in Express View and open the DevTools Console. Click the button to view the list of each favorite food for the dog type.
Overview
The Aggregate operator is used to count the number of entries in a data set. You can also use the operator’s Group Key field, which lets you to group the results into categories based on values from the original data.
For example, consider a Data Table component that stores the details of several dogs and their favorite foods. You'll configure a Data Workflow component to count how many dogs have the same favorite food. In this example , each type of food displays as a separate category using the Group Key field.
Configuration
Configure the Data Table Component
First, you'll add a Data Table component to store a list of dogs and favorite foods that your Data Workflow component can retrieve.
Drag and drop a Data Table component onto your canvas.
In the Property ID and Label Text fields, enter
dtDogs
.In the data table, enter the following:
A
B
name
favoriteFood
Ivy
Peanut Butter
Lucy
Beef Jerky
Wally
Peanut Butter
Nacho
Peanut Butter
Thor
Salmon
Holly
All Foods
Click Save & Close.
Configure the Data Workflow Component
Next, you'll add your Data Workflow component and bring your data into the Data Workflow using an Input operator. Then, you'll add an Aggregate operator to count how many dogs have the same favorite food. But to get an accurate count, you must count the names associated with each favorite food. So, you'll set the Aggregate operator to use the Value Key of name
and Group Key of favoriteFood
. Lastly, you'll view the result using a Console operator and the DevTools Console.
Drag and drop a Data Workflow component onto your canvas, placing it below your Data Table component.
In the Canvas Label Text and Property ID fields, enter
dwfFavoriteFood
.
Configure the Input Operator
Drag and drop an Input operator onto your Data Workflow canvas.
Configure the operator's Info window as follows:
Setting
Value
Category
Input
Component
dtDogs
Required
Yes
Source
Default
Configure the Aggregate Operator
Drag and drop an Aggregate operator onto your Data Workflow canvas.
Configure the operator's Info window as follows:
Setting
Value
Category
Aggregate By
Label
Favorite Food Counts
Aggregation Type
Count By
Join Group Keys
Yes
Group Key
favoriteFood
Value Key
name
Connect the output port (right) of the dtDogs Input operator to the input port (left) of the Favorite Food Counts Aggregate operator.
Configure the Console Operator
Drag and drop a Console operator onto your Data Workflow canvas.
Configure the operator's Info window as follows:
Setting
Value
Category
Console
Label
How many dogs have the same favorite food?
Connect the output port (right) of the Favorite Food Counts Aggregate operator to the input port (left) of the How many dogs have the same food? Console operator.
Here's how the completed workflow looks:
Click Save.
Configure the Button Component
Now, you'll add a Button component to trigger the Data Workflow. Clicking the button executes the Data Workflow and counts the number of dogs who have the same favorite food.
Drag and drop a
Button component onto your canvas, placing it below the Data Workflow component.
In the Property ID, enter btnFavoriteFood.
In the Label Text, enter
Count Favorite Foods
.From the Action Type drop-down, select Event.
From the Trigger on Click drop-down, select dwfFavoriteFood.
Click Save.
Save your module.
Here's how your module looks in the Module Builder:
Preview your module in Express View and open the DevTools Console. Click the button to view the list of each favorite food for the dog type.