Skip to content

Lesson 18 ยท Loops, Variables and Components

KNIME Flow Variables Explained

Use KNIME flow variables to replace fixed node settings, create them from tables or widgets, pass them between nodes, and debug common variable problems.

So far, every setting in your nodes has been typed by hand: a file name, a threshold, a region. That breaks down when the value changes each run. A flow variable is a named value that travels along the workflow and can replace a node setting. It is KNIME's version of a variable in programming.

What a flow variable is

A flow variable has a name, a type (such as text, whole number, decimal, or true/false), and a value. Instead of typing 2026-11 into a file path, you create a variable month and let the reader use it.

Three steps

Create Variable Creator, table, widget
Pass Along connections
Use Overwrite a setting
1 / 2

Creating variables

Common ways to create flow variables are:

  • Variable Creator: type names and values directly.
  • Table Row to Variable: turns the values of a table row into variables, which is handy for settings kept in a configuration table.
  • Configuration and widget nodes: let a user choose a value.
  • Exporting a node setting: many settings can be published as a variable for later nodes.
  • Variable Expression: calculates a new variable with an expression.

Using a variable in a setting

In the current interface, a flow variable icon sits next to settings that support it. Click it and choose a variable from the list. Older dialogs also have a Flow Variables tab for the same purpose. When a setting is overwritten, the dialog warns you, and the typed value in the field no longer matters.

The variable must reach the node. A node sees variables from nodes connected upstream of it. If your variable comes from a separate branch, connect it with a flow variable port. You can show these ports and draw a connection from the node that creates the variable to the node that needs it.

A worked example

Imagine a monthly export with one file per month. The goal is to change one value and have the whole workflow follow.

TEXT
Variable Creator (month = "2026-11")
  -> Variable Expression (file_name = "orders-" + $$["month"] + ".csv")
  -> CSV Reader (path overwritten by a variable)
  -> Row Filter -> GroupBy -> Excel Writer

In expressions, a flow variable is written with two dollar signs: $$["month"]. For the reader, you may need a path variable instead of plain text, in which case KNIME has nodes that convert between strings and paths.

Python Stand-in: build names from one variable

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Change the one argument and every dependent name changes. That is the benefit of variables.

Configuration tables

If a workflow has many settings, keep them in a small table:

setting value
min_amount 25
region North
tax_rate 0.2

Read the table, turn it into variables, and use them in nodes. Non-programmers can edit the table safely. Validate values after reading: a missing or negative min_amount should stop the workflow.

Python Stand-in: validate settings before use

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Debugging variables

  • Open the node monitor's flow variable view to see which variables exist at a port, with their current values.
  • If a variable is missing from the list, check the connection path.
  • Two variables with the same name can shadow each other. Use specific names such as report_month.
  • After changing a variable, re-execute downstream nodes and check that the output changed as you expect.

An overwritten setting can be invisible to a casual reader, who sees one value in a dialog while the variable supplies another. Label the node, for example "path comes from month variable". Do not store passwords in ordinary flow variables; use credential features.

Types and conversions

A flow variable has a type, and settings expect particular ones. A number stored as text may not appear as a choice for a numeric setting. If the list of available variables seems empty, check the type first. Create the variable with the right type, or convert it with an expression before using it. When reading a settings table, check each column's type, because a value like 25 may arrive as text if another cell in the same column holds words.

Exporting settings

Variables flow in both directions. Besides overwriting a setting, you can publish a setting as a variable, so later nodes can use it. Another common pattern is computing a threshold from the data, such as the highest amount last month, turning it into a variable, and using it in a filter. Keep such chains short and label them, since values that come from data can surprise you. If the input table is empty, for example, there is no value to use, and the downstream step should not carry on as if there were.

Naming and scope

Choose names that describe meaning, such as report_month or minimum_order_amount, instead of var1. Within a component, variables are local by default, which keeps names from colliding with the outer workflow. Document any variable that the outer workflow must provide. A short annotation listing the inputs of a workflow helps the next person more than any naming rule.

Practice task

Create variables for a minimum amount and a region. Use them in two filters, and add a check that stops the run when the minimum is negative. Then change each variable and confirm that the output changes in the way you predicted.

When a variable is the wrong choice

Variables are for single values that control a workflow. They are not a good way to move large amounts of data, and a long list of settings spread across many variables is hard to follow. If you find yourself creating dozens of them, keep the information in a table and join or loop over it instead. Also avoid using a variable for a value that never changes. A plain setting with a clear node label is easier to read than an unnecessary layer of indirection.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does a flow variable let you do?

    Variables parameterize node settings.
  2. 2. In an expression, how do you refer to a flow variable named month?

    Double dollar signs refer to flow variables; a single dollar refers to columns.
  3. 3. A node cannot see a variable. What is the first thing to check?

    Variables only travel along connections.
  4. 4. Which node can turn a row of a settings table into variables?

    It converts row values into flow variables.

Summary

  • Flow variables replace hand-typed settings.
  • Create them with Variable Creator, table rows, widgets, or exported settings.
  • They travel along connections, including flow variable ports.
  • Validate settings and use clear names.
  • Check values in the node monitor and never keep secrets in plain variables.

Next: Loops, Switches, and Error Handling

Your progress is saved in this browser. No account needed.