Handling Inactive Branch with Excel Writer

In my KNIME workflow I am attempting to write an excel file containing the raw output from DB Query nodes. The workflow consists of 4 separate processes, where only one is executed using a case switch based on user input. Based on the selected process, only 1 or 2 of the queries will be executed. From the attached screenshot, you can see only queries 1 and 3 are executed. As a result of the middle branch being inactive, the Excel Writer node will not execute. My goal is to replace an inactive branch with an empty table as a place holder, allowing the writer node to execute. I’ve spent some time trying to achieve this, but haven’t gotten any success. There is the node “Active Branch Inverter” which essentially does the opposite of what I need. Unfortunately, there is no “Inactive Branch Inverter” so I’m not even sure if my desire is
possible. Any help/suggestions are greatly appreciated.

Inactive Branch

Hi @JGebhard , what construct are you using that causes the second DB Query Reader to be inactive? Is that branch already inactive on calling the component?

Presumably all three queries connect to different databases, since you have three separate DB session connectors?

Normally a branch is made inactive using case switch or if switch, and you’d make it active again at the other end by closing that construct.

The inactive branch inverter actually reverses the state of a branch so it would make an inactive branch active, but of course this is no use because it would then make it inactive should the branch ever be active!

Ideally you’d want a “branch activator” which somehow makes a branch active, or leaves it active, but that doesn’t exist so we need to work out what construct we can use, or somehow rearrange the workflow slightly.

Any more information about the conditions and flow that makes the branches inactive would be useful. I’m sure we can find a solution but it may involve a small amount of refactoring.

btw, which version of KNIME are you using?

EDIT: As an additional thought, if you are stuck for time, you could always use separate Excel writers, with each writing to a different sheet on the same file, but make sure they’re set to append rather than overwrite the file.

Hi Brian,

  • I am using v4.7.2

Your assumption is correct, I am connecting to 3 separate Databases. I would be more than happy to provide more detail. When executed, the user will be prompted to select between “MS”," ID", “LA”, or “WA”. I have a rule engine variable controlling which queries are executed based on the selection (prediction2). Regardless of the user’s selection, query 3 will be executed. MS only needs query 3, so it is assigned active port 0, which bypasses both queries 1 and 2. Selections for ID and LA requires query number 2 which is assigned to active port 1. Lastly, WA needs query 3 which is assigned to active port 2.

Thanks for the additional info @JGebhard

Ok, so just to clarify my understanding…

  1. whenever this executes, Either Query 1 or Query 2 (or neither) will execute… but never both
  2. Query 3 will always execute.
  3. The result is that either the top and bottom output ports are active or the middle and bottom output ports, or just the bottom port on the component are active

I think I can see a solution, but I need to check a couple of things

You are absolutely correct!

Hi @JGebhard May I suggest modifying slightly so that you have a rule defining two variables similar to what you currently do, but controlling Q1 and Q2 separately. It creates an empty table if the query isn’t executed, and so keeps the resultant branch active?

Would that work for you?

That is sort of the solution I was thinking. I also just created a workflow based on your EDIT from the first response. Writing to the same file with the append setting worked like a charm. I threw some wait nodes to avoid any errors and it’s performing perfectly. Brain, thank you so much for your time and effort!

Append Excel

1 Like

You’re welcome @JGebhard. And thanks for marking the solution. Yes the wait is probably a good solution. Ordinarily I’d say to chain those three Excel writers with flow variables so that two cannot execute concurrently but of course if one is inactive, that would then fail… :wink:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.