Skip to main content

 

After getting familiar with loops, in this current article we will discover another key factor of using KNIME with full potential. Flow variables in KNIME are the equivalent of parameters or variables in programming languages. They are dynamic entities that can be created, manipulated, and utilized within a KNIME workflow. These variables are flexible and can hold values of different types, including integers, strings, and doubles. The primary purpose of flow variables is to enhance the adaptability and control of KNIME workflows, allowing users to dynamically adjust various aspects of their data analysis processes.

 

Uses of Flow Variables

 

Flow variables serve multiple purposes within KNIME workflows, offering users a wide range of functionalities:

Dynamic Execution Control: One of the key uses of flow variables is to control the execution order of nodes within a workflow dynamically. This capability is particularly useful when certain nodes need to be executed before others based on specific conditions or criteria. By defining flow variables that determine the execution sequence, users can ensure that their workflows adapt to changing requirements or input conditions.

Node Configuration: Flow variables enable users to overwrite the settings of nodes dynamically. This feature provides greater flexibility as it allows the behavior of nodes to be adjusted based on the values of flow variables. For example, users can configure nodes to perform different actions or calculations depending on the values assigned to flow variables at runtime.

Information Transfer: Flow variables facilitate the seamless transfer of information between nodes within a workflow. This functionality is essential for passing data generated or processed in one part of the workflow to subsequent stages for further analysis or processing. By connecting nodes using flow variable connections, users can ensure that relevant data is propagated throughout the workflow efficiently.

Implementing Flow Variables

 

Implementing flow variables in KNIME involves two main steps: creation and utilization.

Creation

Flow variables can be created in two ways:

Global Flow Variables: These variables are created at the workflow level and are visible throughout the entire workflow. Users can create global flow variables by right-clicking on the workflow in the “KNIME Explorer” view and selecting “Workflow Variables”.

Local Flow Variables: These variables are created within specific nodes and are only visible within the scope of those nodes. Local flow variables can be created using Quickform nodes or nodes that have a flow variable output port.

Utilization

Once created, flow variables can be utilized in various ways:

Execution Control: To control the execution order of nodes, users can connect nodes using a flow variable connection, denoted by a red edge. By defining conditions based on flow variables, users can determine when certain nodes should be executed within the workflow.

Node Configuration: Flow variables can be used to overwrite node settings dynamically. Users can navigate to the “Flow Variables” tab in the node configuration dialog and select the appropriate flow variable to adjust the settings of the node accordingly.

Information Transfer: Flow variables facilitate the transfer of information between nodes by connecting them using flow variable connections. This allows data generated or processed in one part of the workflow to be passed to subsequent nodes for further analysis or processing.

 

Examples of Flow Variables in KNIME

 

To illustrate the practical application of flow variables in KNIME, consider the following examples:

Data Filtering: Suppose you have a dataset containing employee data from different countries, and you want to analyze data from a specific country. You can create a flow variable that holds the name of the country and use it in a “Row Filter” node to dynamically filter the data based on the selected country.

Dynamic Node Execution: Staying with the previous example, imagine you have to create employee reports based on their continent. You would like to run Europe report in the morning, North America in the afternoon, and Pacific at night. By creating a flow variable that holds the current time, you can dynamically control the filtering,  ensuring that specific continents are performed at predetermined times.

 

The workflow containing both examples can be accessed or downloaded from this link.

Conclusion

 

Flow variables are a powerful feature of KNIME that offer users greater control and flexibility over their workflows. By understanding how flow variables work and how they can be implemented and utilized within KNIME workflows, users can enhance the efficiency and effectiveness of their data analysis processes. Whether controlling the execution order of nodes, overwriting node settings dynamically, or facilitating the transfer of information between nodes, flow variables provide a dynamic framework for customizing KNIME workflows to meet diverse analytical requirements. With their versatile capabilities, flow variables empower users to tackle complex data analysis tasks with ease and efficiency.

 

Author: Marcell Palfi, Data Engineer, Datraction

Leave a Reply