# Filter to group

**URL:** <https://forum.knime.com/t/filter-to-group/45849>\
**Category:** KNIME Analytics Platform\
**Created:** [August 10, 2022, 11:24am UTC](https://forum.knime.com/t/filter-to-group/45849 "2022-08-10T11:24:40Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![umbs](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/u/c37758/32.png) [@umbs](https://forum.knime.com/u/umbs)\
**Post date:** [August 10, 2022, 11:24am UTC](https://forum.knime.com/t/filter-to-group/45849/1 "2022-08-10T11:24:40Z")

</div>

Hello everyone,  
I state that I am a beginner, I expose my requirement / problem.

I have a table with 20 columns containing nuneric information and one final column, which is noninal, and can contain the values Green or Red.

I would like to search for the optimal filter that groups the highest value for Green and lowest for Red.

For example if the twble contains 100 rows a good result could be:

60 green  
15 red

Is there any way to get it?

Thank you all.  
Umberto

---

<div class="post-metadata">

**Author:** ![elsamuel](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/e/b4bc9f/32.png) [@elsamuel](https://forum.knime.com/u/elsamuel)\
**Post date:** [August 10, 2022, 12:45pm UTC](https://forum.knime.com/t/filter-to-group/45849/2 "2022-08-10T12:45:50Z")

</div>

Welcome to the forum, @umbs

I’m not sure I understand the logic here.

> 60 green  
> 15 red

What are these numbers?

---

<div class="post-metadata">

**Author:** ![umbs](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/u/c37758/32.png) [@umbs](https://forum.knime.com/u/umbs)\
**Post date:** [August 10, 2022, 12:48pm UTC](https://forum.knime.com/t/filter-to-group/45849/3 "2022-08-10T12:48:11Z")

</div>

Hi,  
Number of rows grouped by last column.

---

<div class="post-metadata">

**Author:** ![ArjenEX](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/a/97f17d/32.png) [@ArjenEX](https://forum.knime.com/u/ArjenEX)\
**Post date:** [August 10, 2022, 3:53pm UTC](https://forum.knime.com/t/filter-to-group/45849/4 "2022-08-10T15:53:02Z")

</div>

Hi @umbs  
Am I right that you are looking for the largest group of consecutive rows of either green or red?

Something like this:  
Create a sequence of consecutive greens or reds  
 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/c/2/c2ea2cf90c0b022c31ce6b123cde6e0ac301bcdc.png)

And then find the max values within the entire dataset?  
 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/3/6/363740d70baa03ccb28671648e532db3a2e2c44c.png)

In general, try to be as complete as possible in your questioning. Include current input, expected output, screenshots, data sets, workflows, etc. as much as possible in the beginning. The more you provide, the more accurate the help will be 😉

---

<div class="post-metadata">

**Author:** ![umbs](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/u/c37758/32.png) [@umbs](https://forum.knime.com/u/umbs)\
**Post date:** [August 11, 2022, 6:00am UTC](https://forum.knime.com/t/filter-to-group/45849/5 "2022-08-11T06:00:44Z")

</div>

Hi,  
I’m looking for largest group with Result Green and lesser group with Result Red (not consecutive).

INPUT:

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/e/9/e9441c6ec252b9bfaaff10f71c156c39ee4ecafc.png)

OUTPUT (best result)  
 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/b/6/b64212f8690c3dcbbf8db4c047e464844b8e6a0e.png)

I would like to find a filter that would group by Result all the records including the greatest number of Green rows and the least number of Red rows using in the condition as many columns as possible, the “distance” between the two groups must be high.

Hope is clear 🙂

Thank you.  
Umberto

---

<div class="post-metadata">

**Author:** ![berserkersap](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/b/eada6e/32.png) [@berserkersap](https://forum.knime.com/u/berserkersap)\
**Post date:** [August 11, 2022, 7:15am UTC](https://forum.knime.com/t/filter-to-group/45849/6 "2022-08-11T07:15:04Z")

</div>

Hello @umbs, welcome to the community  
Am I correct to assume that your requirement is more towards ML clustering ? [binary classification]  
Also it seems you also need to find a function or technique like SVM, regression etc to label your result as GREEN or RED using the 18 columns.  
And when you speak of distance, how is it supposed to be calculated ?  
Though if you just need the count of GREEN and RED (after getting the best result), you need to use group by node on result column with count aggregation 😅

---

<div class="post-metadata">

**Author:** ![ArjenEX](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/a/97f17d/32.png) [@ArjenEX](https://forum.knime.com/u/ArjenEX)\
**Post date:** [August 11, 2022, 8:11am UTC](https://forum.knime.com/t/filter-to-group/45849/7 "2022-08-11T08:11:42Z")

</div>

To be honest, I don’t see any column that can be used as group based on your screenshot. If you have a proper group column somewhere which designates this, the GroupBy Node is a proper fit.

If you’re just looking for a color count, like in your screenshot, I would use the **Value Counter** node.

![image](https://forum-cdn.knime.com/uploads/default/original/3X/9/4/9483e72ad8a72d0a03eb47caf4841fb931b7b742.png)

![image](https://forum-cdn.knime.com/uploads/default/original/3X/c/c/cc9b77d08dd6316fd93de642b48222d9ae616d29.png)

---

<div class="post-metadata">

**Author:** ![umbs](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/u/c37758/32.png) [@umbs](https://forum.knime.com/u/umbs)\
**Post date:** [August 11, 2022, 8:21am UTC](https://forum.knime.com/t/filter-to-group/45849/9 "2022-08-11T08:21:25Z")

</div>

Yes, in depth this is a backtest. I would like to found a good filter that use much columns in order to have many Green rows.

---

<div class="post-metadata">

**Author:** ![Daniel\_Weikert](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/d/e47c2d/32.png) [@Daniel\_Weikert](https://forum.knime.com/u/Daniel_Weikert)\
**Post date:** [August 11, 2022, 4:33pm UTC](https://forum.knime.com/t/filter-to-group/45849/10 "2022-08-11T16:33:45Z")

</div>

I don’t see any group and (probably) don’t understand the goal correctly but you could treat it as a binary classification problem, map colors to 1 and zero and then train a ml model on it. This can give you the importances of each column contributing to the color.  
br

---

<div class="post-metadata">

**Author:** ![system](https://forum-cdn.knime.com/uploads/default/original/1X/ab3ccf34482a0329361734a18199390177204f15.png) [@system](https://forum.knime.com/u/system)\
**Post date:** [November 9, 2022, 4:34pm UTC](https://forum.knime.com/t/filter-to-group/45849/11 "2022-11-09T16:34:09Z")

</div>

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