If switch / Case switch (if exists at least one row with a particular condition)

Hi friends,
I would like some help with if switch or Case switch.


I have a workflow and I’m using a node to identified if there is a duplicated value in a particular column.


In this example, there is.

What I need:

How can I build a rule that validates the table and checks the following rule:

if in the “duplicate status” column there is at least one line with the word “chosen”, then do not move to the DB port, otherwise, move to the DB port.

My difficulty is identifying whether there is at least one line with the information. Because if it doesn’t exist, it means that all cases are “unique” and I can pass it to the DB, as it won’t give a “primary key” error in the database.

I created a simple workflow to help any friend who could help with this problem.

duplicate_teste.knwf (10.6 KB)

Well, I don’t know if it’s the best strategy, but I have achieved a result as follows:

  1. First I grouped the column “duplicate status” to find how many rows exists.
    (if exists more them one row, it means that at least one value is different than unique)

  2. I grouped again to count the rows to find if the value is more than one row.

  3. I use a “rule variable” to passes to the port


Question: There is another, intelligent, way?

I’m always curious to know if there is a smarter formula with array or a formula using “column expressions” to find if exists at least one particular value in the column of all rows

Hi @Felipereis50

I’d say you are going the right direction there. Don’t think there is anything much quicker. My approach would be to create a unique list of the duplicate type classifiers, convert it to variable and then determine if the word chosen is in there.

if (contains(variable("duplicate-type-classifier"),"chosen") == true) {
} else {


Thanks my friend.
Another formula for me to learn. :grin:

Cheers :brazil:

1 Like

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