Unique Operator
Overview
Working with data, you might only want to see unique values from a data set. That's where a Unique operator comes in handy. Here's an example:
Say your application asks end-users which country they're from. Chances are good you'll have more than one end-user who gives the same answer, right? Well, if you only want to see each unique country, you'll use a Unique operator in your Data Workflow.
You'll find the Unique operator under the Table group to the left of the Data Workflow canvas.
What You'll Learn
In this
Info Window Settings
Here's what the operator looks like, along with its Info window:
And here's a breakdown of each setting in the Info window:
Setting |
Description |
---|---|
Label |
Sets the label for your operator. The label you enter here shows beneath your 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. |
Unique Keys |
Tells the operator which data to retrieve unique values from. When working with a table, this would be the name of the column. For example, if you have a column labeled country, you'd enter country here. NOTE Keys are case sensitive and must match the capitalization of your column labels. |
Adding a Unique Operator
To see a Unique operator in action, let's look at an example. You'll create a Data Table that holds a list of countries. In the Data Table, you'll include a couple of duplicate entries. Then, you'll set up a Data Workflow to weed out the duplicates.
Here's how the completed use case will look in the Module Builder:
Here's how the completed use case will work in Express View, including a peek at the DevTools Console:
What You'll Need
To set up this use case, you’ll need:
-
1 Data Table component
-
1 Hidden component
-
1 Data Workflow component
To set up your Data Workflow, you'll need:
-
1 Input operator
-
1 Unique operator
-
1 Output operator
Configure the Data Table Component
First, you'll set up your Data Table. Keep in mind that you're intentionally including duplicate entries here. This is important for demonstration purposes.
1. | Drag and drop a Data Table component onto your canvas. |
2. | Enter dtCountries in the Label and Property Name. |
3. | In column A of the data table, enter the following: country, Afghanistan, Albania, Algeria, Cambodia, Czech Republic, Andorra, Austria, Afghanistan, Albania, Algeria, Afghanistan. |
4. | Click Save. |
Configure the Hidden Component
Before you can add your Data Workflow, you'll need a place to store its output. You'll use a Hidden component for that.
1. | Drag and drop a Hidden component onto your canvas. Place your Hidden component below your Data Table. |
2. | Enter uniqueCountries in the Property ID and Label Text. |
3. | Click Save. |
Configure the Data Workflow Component
1. | Drag and drop a Data Workflow component onto your canvas. Place your Data Workflow above your Hidden component. |
2. | Enter dwfUnique in the Canvas Label Text and Property Name. |
3. | Set the Trigger Type to Watch. |
Configure the Input Data Operator
1. | Drag and drop an Input operator onto your Data Workflow canvas. |
2. | Configure the Input operator's Info window as follows: |
Setting |
Value |
---|---|
Category |
Input |
Component |
dtCountries |
Required |
Yes |
Source |
Default |
Configure the Unique Operator
1. | Drag and drop a Unique operator onto your Data Workflow canvas. |
2. | Configure the Unique operator's Info window as follows: |
Setting |
Value |
---|---|
Category |
Unique |
Label |
Show Unique Countries Only |
Unique Keys |
country |
3. | Connect the output port (right) of the Input operator to the input port (left) of the Unique operator. |
Configure the Output Operator
1. | Drag and drop an Output operator onto your Data Workflow canvas. |
2. | Configure the Output operator's Info window as follows: |
Setting |
Value |
---|---|
Category |
Output |
Component |
uniqueCountries |
Action |
value |
3. | Connect the output port (right) of the Unique operator to the input port (left) of the Output operator. |
4. | Click Save. |
5. | Save your module. |
Now it's time to test your Data Workflow! Preview your module in Express View and then open the DevTools Console. You'll see your Hidden component holding a list of countries, but each country only appears once.
Changing a Unique Operator's Settings
You can revisit and make changes to this operator.
1. | Click the Data Workflow component. |
A 5-button toolbar displays above the component on hover-over.
2. | Click the (Settings) button to open the Data Workflow canvas. |
3. | Click the operator to open its Info Window. |
4. | Make changes to the operator's settings as needed. |
5. | Click Save. |
6. | Save your module. |
Copying a Unique Operator
You can make a copy of your operator using familiar keyboard settings. You can copy and paste an exact copy of your operator, matching all settings.
1. | Hover over the Data Workflow component. |
A 5-button toolbar displays above the component on hover-over.
2. | Click the (Settings) button to open the Data Workflow canvas. |
3. | Click the operator you want to duplicate. |
4. | On your keyboard, press Command + C (Mac OS) or Ctrl + C (Windows/Linux) to copy the operator. |
TIP You can copy more than one operator at a time. Hold Command or Ctrl on your keyboard and click all the operators you want to copy. Follow the rest of the steps as usual.
5. | On your keyboard, press Command + V (Mac OS) or Ctrl + V (Windows/Linux) to paste the copied operator(s) to the Data Workflow canvas. |
6. | Click Save. |
7. | Save your module. |
TIP Did you know you can copy an operator and paste it into a different Data Workflow? You'll use the same steps outlined above.
Removing a Unique Operator
Lastly, you can delete this operator from your Data Workflow canvas. You can also use these same steps to delete a connection between two operators.
1. | Hover over the Data Workflow component. |
A 5-button toolbar displays above the component on hover-over.
2. | Click the (Settings) button to open the Data Workflow canvas. |
3. | Click the operator you want to delete. |
4. | On your keyboard, press Delete. |
NOTE Once you delete this operator, make sure to connect your remaining operators. If your Data Workflow path doesn't end with an Output or Console operator, your Data Workflow won't work. So, once you delete an operator, make sure to update any remaining paths to end at an Output or Console operator.
5. | Click Save. |
6. | Save your module. |
Lab
You can view this complete use case here: https://training.unqork.io/#/form/5f4febc71959bf0217f5472b/edit.