Subtracting from one value column based on different criteria

I have a table that looks like this:

Name company Month values
Revenues A Jan 100
Revenues A Feb 200
Revenues B Jan 300
Revenues B Feb 400
Revenues C Jan 500
Revenues C Feb 600
Costs A Jan 10
Costs A Feb 20
Costs B Jan 30
Costs B Feb 40
Costs C Jan 50
Costs C Feb 60

I now want to calculate reveneus - costs, depending on Month and Company.
So f.e. Revenues from Company A and from Jan - Costs from Company A and from Jan.

Any idea how I could do this?

Thanks in advance

Hi @Philippfk , Welcome to e KNIME community.

The GroupBy node would do these calculations for you. Group by “Name” and “Company” or “Name” and “Month” with aggregation as “sum” of values will give you the different totals.

Hey @takbb,

thanks for your reply!
I already did that, the column values is already filled with the totals. However, now I want to subtract the totals from “revenues” and “costs”

My apologies @Philippfk , I misread your post. Ok, i would probably pivot the data as follows:

[Edit - ticked “retain row order” on advanced settings! ]

This will then give you a table in the following form, from which you can then use Math Formula to perform your calculations


Of course! Thank you @takbb

1 Like

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