Count only the first event in the year

I can’t solve this simple node.
I’ve a list of event which can happened twice or more during a year.
I need to give a value of 1 to the first event of the year and if there’s more, they get the value 0.
This in order to obtain the count of the x unique events happened with a simple sum.
I know it’s very simple but I can’t realize how to solve it!

This is a table with the event list. The last column is the result i would obtain.

2017-03-27T00:00 2017 139 1
2017-06-28T00:00 2017 139 0
2018-02-21T00:00 2018 139 1
2018-07-04T00:00 2018 139 0
2018-10-16T00:00 2018 139 0
2019-01-23T00:00 2019 139 1
2019-07-31T00:00 2019 139 0
2017-07-17T00:00 2017 210 1
2017-09-30T00:00 2017 228 1
2018-09-15T00:00 2018 228 1
2017-01-11T00:00 2017 240 1
2018-03-06T00:00 2018 240 1
2017-04-03T00:00 2017 263 1
2017-07-17T00:00 2017 263 0
2018-01-08T00:00 2018 263 1
2018-07-23T00:00 2018 263 0
2019-03-25T00:00 2019 263 1

Thanks for your help.

Welcome to KNIME forum. You can use GroupBy node to count number of unique events using eventid for and Unique count as a function.


Yeah, ok. But i don’t need to count the times. I need to ASSIGN FOR EVERY ROW the value:

1 - For the first event in the year
0 - If the same event happened after the first one and is within the same year.

With GroupBy can I do this?

Use function First or Min on the date field. Then use join to join result to the original table by rowID and then use Rule Engine to assign 1 or 0 based on the date added as first.


Thanks! It’s work. Was so easy… :wink:

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