# Perform Mathematical Operations on Column Values for the Same Row

Hello,

I have been stuck working on this for a few days without success so I would really appreciate the help of Knime community.

I have an input in the following format:

Input Scenario 1

What I would like to achieve is to calculate the minimum value for every row based on the number of weeks given in the last column.

Output:

I am currently facing two problems, the first one is that the column headers are changing based on the report date and that the (No. Weeks) is changing as well between different input reports (but it is always the same No. of weeks in all rows per report).

To make it more clear, below is another input scenario:

Input Scenario 2

Output

Your help would be appreciated on this one.

Input.xlsx (10.5 KB)
Output.xlsx (10.6 KB)

Hi,

I usually transform a matrix input always to a single value per row.
So this should be done with an â€śUnpivotingâ€ť node and you have to define a rule (here column name contains â€śWKâ€ť). Then the calculation/aggregation should be quite easy.

Z_003_Unpivot.knwf (9.7 KB)

2 Likes

Hi @amrzahran,

Do you need the min value of the first n columns?

2 Likes

@armingrudd Exactly Armin, this is what i am looking for.

Then you can use

with Minimum function.

3 Likes

Ok, it getâ€™s a little more complicated.
However I would stick to the approach to transform your input first via â€śUnpivotingâ€ť.
Then Group Loop Start for â€śProductâ€ť and a rule-based row filter in order to catch the first n rows (= weeks). The minimum is calculated by the GroupBy Node.

See attachedâ€¦Z_003_Unpivot.knwf (16.0 KB)

3 Likes

Thanks a lot everyone for your quick and helpful replies. I really appreciate your efforts and I learned a lot from the various solution approaches provided

All the best.

3 Likes

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