Sum of occurrences

Hi,
I need your help for this requirement:
I have a table like this:

Table 1

A1 A2 A3 A4 A5
2 3 1 4 2
4 2 2 1 2
3 2 2 3 3
3 4 3 2 4

I ned to get something like:

Table 2

V 1 2 3 4
A1 0 1 2 1
A2 0 2 1 1
A3 1 2 1 0
A4 1 1 1 1
A5 0 2 1 1

Where
V is a row with the possible value (1,2,3,4) in the column of table 1
and values in table2 is the quantity of each value in the first table

I get something useful with “statistic node”. Is there any other way to get it in a simpler format (really I have more than 30 columns in my table 1, while 1,2,3,4 is the real set of value in table1) ?

Thanks in advance for your suggestions
Mauro

Hi @mauipm

I create a workflow that takes your table 1 as an input and returns table 2. It is possible to use as many columns as you like. The basic for this flow comes from looping over columns from the KNIME hub .

sum_of_occurences.knwf (58.8 KB)

Succes, gr. Hans

1 Like

1000 Thanks, Hans
very interesting and useful !!!
Mauro

1 Like

Hi there,

this sounds like a task for (Un)Pivoting nodes :slight_smile:

Pivoting

2019_06_07_(Un)Pivoting.knwf (10.3 KB)

Br,
Ivan

Thanks a lot, Ivan, so clean and simple :slight_smile:
Mauro

2 Likes

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