Flow Variables

Flow variables are used in KNIME to paramterize workflows when [[Node Settings]] need to be determined dynamically.  Flow variables are carried along branches in a workflow via data links (black edges between nodes) and also via explicit variable links (red edges between nodes).  Flow variable ports can be enabled on any node via Right Click > Show Variable Ports.

Two of the most important applications for flow variables are the configuration of [[Loops]] and [[Meta Nodes]] using [[Quickform Nodes]].

There are flow variables of different types, you can use them for numbers and strings.

 

  1. Example:
  • If you want to evaluate different number of clusters in a loop you don't want to set up multiple branches each having the same configuration but only a different number of clusters configured. 
  • This is done in our example workflow 011003_loopParamametersKMeans, which you can download from our [[Example Server]]. 
  • Open the [[Meta Nodes]] Cluster with var k and there open the second tab (Flow Variables) of the configuration dialog.
  • Here you can now select a flow variable for the nrClusters. Here we set it to k and it will change as configured in the Params table in each run.

2. Example

  • The "iterate over list of files" meta node shows you how to read multiple files in a directory. However if you want to read xls or xml files this won't work. Here the flow variables will help you again.
  • Exchange the file reader with the reader of choice (e.g. XLS Reader). Connect the reader with variable port of  the "TableRow To Variable Loop Start" via its [[Optional Flow Variable Ports]]  and open the Flow Variables Tab. The fileUrl must now be set to the String Flow Variable containing your URL.