Add rows together based on criteria of two other columns

Simple question here, but new to KNIME. I have a simple dataset:

Date / Count / DayPart / ItemType

Example attached…say I have red and green apples and I’d like to combine them into a single count per day part per given date. Let’s call the new combination ‘apples’.

Another way to describe the request using the attached data…
I have a count of 2 Red Apples under the Early daypart on 1/1. I’d like to combine their count with the 3 count of Green Apples also under the early daypart of the 1/1 date. Rename the Type of apple to just ‘apples’.

How to do this?

SampleData.xlsx (15.2 KB)

Hi @t2jr0385 -

Here’s one way to do it. Use the Rule Engine node to deal with the apples, and then use the GroupBy node to sum everything up by variables of interest. Download the example workflow to get an idea for how the individual nodes are configured.



RuleEngineGroupByExample.knwf (19.7 KB)

Thanks Scott!

What is the example didn’t have a common word for two color types, such as apple.

What’s the rule engine in place of ‘like’ if say we want to combine orange and banana and call it ‘fruit’?

That advice and I think it’s there.

Thanks again!

Sure, in that case the Rule Engine logic would look something like:

$Type$ = "Oranges" => "Fruit"
$Type$ = "Bananas" => "Fruit"
TRUE => $Type$