Compare all values of all columns and if One value is repeated, the value in the new column created will be "1"


#1

Hello,

I need your help for this situation please:
I have many columns and I have to compare values of each column( values of the same row), and if i find one Repeated value, the value of the new column created ( in the same row) will be “1”.

PS : I have to compare just if the value is not null.
Thanks for your help !!.
I will be grateful,
Best regards.
And sorry for my bad english :’(.


Comparing All values of many columns of the same row
#2

Hi!

You can try following:

Table Row To Variable Loop Start node (loop over row)–> Transpose node (to have it in column format) --> Row Filter or Missing Value node (to remove missing values) --> GroupBy node (to count unique values in Column) & Extract Table Dimension (to get number of rows) --> Now compare those two values and if are same write 0 (?) and if are different write 1 (Rule engine node) --> Loop end (will append everything in one column with 0s and 1s)

You will probably need Column Filter/Appender node in loop to have only table 1x1 (with 0 or 1 in it) at the end.

I haven’t test it. Try it out and give me feedback. Good luck :smiley:

Br,
Ivan


#3

If you have some time to try it i will be grateful :wink:.


#4

Hi!

Of course you can not connect it :slight_smile: My bad.
You should first transpose and then use different loop start. Here is a picture. Give it a try.

Br,
Ivan


#5

@ipazin , Thank youuu a lot.

Can you send me this workflow please to know how I can do the setting for each node ?

:blush:


#6

Hmmmm. Nop :smiley:
I prefer people try it them self and if you have trouble with certain node setting just ask. I even wrote node descriptions :wink:
Br,
Ivan


#8

for the GroupBy I do this setting :


but the first Rule Engine how to Add Number Of Rows ?.
And I can’t find the node : “Column Expressions”

Thank’s for your help again :blush:
Best Regards!


#9

Hi @TIZIZ -

The Column Expresssions node, new to KNIME 3.6, is available in the KNIME Expressions extension.


#10

Hi @ScottF,

thank you for your help.

if I upgrade to the new version 3.6, I may loose my workflows and data ? .

Bests Regards.

:slight_smile:


#11

Upgrading shouldn’t affect anything negatively, but if you want to be 100% safe, you can always back up your workspace folder prior to the upgrade.


#12

Hi!

In group by node in each loop iteration you need different Row. So first time it is Row0, then Row1, Row2…
You will get this by controlling aggregation column name with flow variable. When you use this loop there is automatically created flow variable currentColumnName with name of current column in loop. Use it.

In Rule engine node if you use TRUE => 1 you will add (or replace depending on node configuration) column with all 1s. This way you can use TRUE => “flow variable name” that holds number of rows.

Br,
Ivan


#13

Hi !
thank you for your attention!

Can you explain your logic because here we compare numbers and I need to compare ( String) because all columns there type is String.
And what I should do in the first 'Rule Engine’Node ,

I don’t understand how to add numbers ?? because here for the first time I have “Row0” ( I know that the loop will treat for each iteration)

it a little bit hard for me to understand this because is the first time for me that i’m using these concepts.

Thank you again.
Bests Regards.


#14

Hi!

My idea is to compare number of unique values in row with total number of values in that row so it doesn’t matter if you have numeric or string values. If the number is same then all values in that row are unique so you will put 0. Else you put 1 because there is less unique values then the total number of values in row meaning you have one or more values repeated.

In this Rule engine node you add following rule:
TRUE => Number of Rows (double click from Flow Variable list)

Br,
Ivan


#15

Hi again !

I will have to come back to you on that again ,

1- I haven’t finshed the workflow yet, and I wanted to test the Loop operation. I get that Error in the Group By :


How I can fix it, Sorry for annoying you !, but i’m new in tha manipulation of flow variables.
2- for the column expressions, I haven’t find it even I upgrate the version to knime 3.6.

Thank you :slight_smile:.
Bestes Regards.


#16

Hi @TIZIZ -

To get the Column Expressions node, you have to install the KNIME Expressions extension, shown here:


#17

No problem. You should go through some tutorials regarding Knime. That is good (mandatory) for start. Then creating workflows will be easier and more fun :slight_smile:

Here is a one for flow variables. Flow variables are controlled on flow variables tab :wink:

https://www.knime.com/knime-introductory-course/chapter7/section1/creation-and-usage-of-flow-variables

Br,
Ivan


#18

Hi ScottF,

After upgrading to knime 3.6, I wanted to add the extensions of “Knime Expressions” and I get this Error:
cap2

PS: I don’t have the probleme of Firwall.
How I can fix it Please!
@ipazin wish one of Attribute that i have to add the CurrentColumnName variable in these parametrs:


And what is the goal of using the Column expressions and how to parameter it ?
Thank you very much for helping me, really I need your support ! :slight_smile:
Best Regards !


#19

Hi @TIZIZ!

Click a little bit and you will find it :slight_smile:

As you are doing manual aggregations then it is under aggregationColumn --> columnNames

Here 0 represents first column or in your case only column you have added on Manual Aggregation tab.

Regarding column expressions node it is used only to calculate difference and you do not have to use flow variables here. You just subtract two columns. But first install this node, read its description and you can use Knime NodePit (https://nodepit.com/category/) to find example workflows with it :wink:

Br,
Ivan


#20

Hi @ipazin,

is this the configuration that I have to do in “0” attribut !!! :

Thank you again !
Br.


#21

Yes :slight_smile:
Ivan