Count if / Count - flat in a new column

Hello Knime Community,

i’m sorry. I’ve come up with a supposedly simple question, but despite research and attempts, I’ve been unable to answer it. I am just switching from Excel/Access to Knime. Analogous to the “count-if” function or “sum-if”, I would like to analyse my data.

In Knime I have tried the nodes “Value counter”, “group by” or “maths”. The value counter already brings me to the goal without an “if attribute”. However, I no longer have the original table available.

So I am looking for a node that searches “flat” for the number in a column in the corresponding row.

I hope someone will take a moment! Thanks in advance!

|Value|Counter|
|— |—|
|V_a | |
|V_b | |
|V_c | |
|V_a | |
|V_c | |
|V_c | |

|Value|Counter|
|V_a | 2 |
|V_b | 1 |
|V_c | 3 |
|V_a | 2 |
|V_c | 3 |
|V_c | 3 |

Count.knwf (10.2 KB)

I would now like to add an additional if-condition or extend the counting range via two columns. The if-attribute here is simply cell content from column Value.

Hi @UGChris . Welcome to the forum!

If I understand you correctly, you want the original table but with the count of the occurrences of each value?

ok. so what you need to realise is that just because you’ve used the Value Counter, you can still bring the info from that back into another node along with your original table by using a Joiner node. So take a dataflow as in the attached workflow and join the original data table with the output from Value Counter using the “key” columns from both tables. You can take multiple flows OUT of each black triangle on a node, but only a single data flow can flow IN to any one black triangle on a node.

image

image

Count-2.knwf (8.4 KB)

Hope that helps, but if I’ve misunderstood, post back with further questions.

3 Likes

This works perfectly! I had the Joiner in my hands. But I could not set up the table. Thank you very much. This is getting me further! Have a nice day!

3 Likes

You’re welcome. Coming from Excel and other databases can make workflow/data pipeline tools seem odd at first, but after some playing around it becomes much easier.

1 Like

Thanks again for the motivation! You are absolutely right!

1 Like

@UGChris if you have experience with Excel and want to use that with KNIME and eg. start to automate tasks there are several resources to help you

Also a free book:

https://www.knime.com/knimepress/download-from-excel-to-knime

5 Likes

Hello @UGChris,

you can use Solution button to mark answer as solved (hidden behind 3 dots…), this closes topic faster and helps others find answer sooner :wink:

Additionally I prefer using Cell Replacer node instead of Joiner in case of one key-value pair… Easier to configure and faster :wink:

Welcome to KNIME Community!

Br,
Ivan

3 Likes

Thank you! I was looking for the option but did not regonize! I think now I did it right!!!
Thank you for the welcome! I will look the Cell Replacer as well!

2 Likes

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