a month ago
- edited
3 weeks ago
by
AlteryxCommunit
This article is part of the Tool Mastery Series, a compilation of Knowledge Base contributions to introduce diverse working examples for Designer Tools. Here we’ll delve into uses of the Control Container Tool on our way to mastering the Alteryx Designer:
The Control Container Tool brings dynamic functionality to help build smarter and more flexible workflows. Introduced with version 2023.1, Control Containers add on to what the existing Tool Container Tool brings to the table but goes far beyond grouping and documenting portions of your workflow.
Using Control Containers
To use Control Containers, the AMP Engine must be enabled. The tool itself is found within the Developer Tools ribbon:
Tools can either be dragged directly into a Control Container located on the canvas or groups of tools can be highlighted and then placed into a Control Container using the right-click and “Add To New Control Container” option in the pop-up menu.
To remove a Control Container, you can similarly right-click on the container and elect to “Delete Container Only.”
Lastly, Control Containers can be enabled or disabled in the same way standard containers behave. There is a toggle button near the top-left corner of each Control Container. When toggled off, all tools within the Control Container will be negated.
Now that we know how to introduce them into our workflows and configure them, let’s explore what makes them powerful.
How Do Control Containers Work?
To understand how to use a Control Container, it’s useful for us to consider three key functionalities:
Additionally, when used without connecting to another Control Container, they function just like a standard Tool Container, in that they allow you to group tools, label them, or enable/disable portions of your workflow.
Next, we’ll dive deeper into each of the three core capabilities.
Sequencing Workflows
Let’s begin by exploring how Control Containers allow us to control the order of execution within a workflow. Control Containers allow workflow sections to be sequenced by connecting the containers to each other:
Notice, in the illustration above, the connections between each of the containers. Control Containers have the same Input and Output flags that traditional tools do.
When Control Containers are connected, upstream tools grouped within a preceding Control Container must complete before the next Control Container’s tools will run. They are running in series. In some regards, using this technique can be a more predictable and relatable method than what the Block Until Done Tool offers. There are times when the Block Until Done Tool may run portions of your workflow in what seems to be “out of order” whereas the Control Container more explicitly abides by the sequencing rules.
It’s also worth pointing out that the contained tools can connect across Control Containers (like in Container 2 and Container 3), but they don’t have to (like in Container 1 and Container 2). This powerful functionality gives you the ability to sequence your tools to ensure they run in the order you want regardless of whether (or not) the streams connect across containers.
This is especially useful when you need to ensure large outputs of data are processed before downstream steps begin.
Using Meta-Data as Data
One of the lesser-known capabilities that Control Containers introduced was the ability to peek under the hood and get basic information about the tools being run within the container. This data can be logged, used in downstream conditions that could affect subsequent portions of the workflows, and/or used to help debug warnings or errors in the workflow.
As shown above, simply connecting a Browse Tool allows you to see the logging output from the tools inside the Control Container. You aren’t limited, however, to simply viewing this metadata. This information can also be leveraged further downstream in your workflow.
Conditional Execution
Perhaps the most valuable capability of the Control Container is the ability to execute different streams depending on preceding logical considerations. To accomplish this, the Filter Tool + Control Container combination can be used to dynamically control outcomes.
Consider the following scenario. In the example below, we are checking source data (src_table) against the database destination (dest_table). If the data already exists in the destination table, there is no reason to extract and load the data.
To accomplish the conditional behavior, a test is set up in the Formula Tool by checking the [Date] fields from both data sources. When they are the same, a “True” value is assigned (versus “False” if they are different).
When the logic test yields “True,” the Filter Tool passes a row of data into the upper Control Container. If the test yields “False,” the data flows into the lower stream.
When one or many rows of data are fed into a Control Container, that container will activate the tools within it (one time). Any Control Container that does not get any data fed into it will not be activated at all. In this way, we are, and as the name implies, controlling which container and therefore tools run based on conditions that come directly from the workflow itself. Ultimately, making your workflows react dynamically.
From there, the possibilities of what you can account for are endless!
For more information and example workflows, navigate to the Control Container Tool in Alteryx Designer and select “Open Example”
By now, you should have expert-level proficiency with the Control Container Tool! If you can think of a use case we left out, feel free to use the comments section below! Consider yourself a Tool Master already? Let us know at community@alteryx.com if you’d like your creative tool uses to be featured in the Tool Mastery Series.
Nice job buddy. This is amazing work!
Thank you @jrlindem for this very good read.
Two use cases I would like to add:
1. Control Container Throttling: Adjustable Delay for Control Containers - Alteryx Designer Desktop Ideas
2. Prevent next container from activating in case of error: When you connect one Control Container to another, if the initial Control Container's input anchor is not connected or is connected to an input and receives at least one record from the connected input, it will activate and the next Control Container will also activate, provided no error handling is added.
The screenshot below displays how a basic error handling between two Control Containers can be configured. Most important thing to look out for is to append the Control Container's activation status, as the Control Container might not have been activated and therefore produces no messages at all (including errors). This configuration makes it so that the connected Control Container only activates if the previous Control Container was activated and finished running without errors.
thanks @jrlindem for sharing the most valuable information about tool containers. This is enough information
Please give my idea to Add Tool Name Column to Control Container metadata output an upvote!