Percentage Value to Column

Hi-

Is there any way I can get percentage value from example below.

Name Class Score
Ariel Math 85
Ariel Physics 60
Ariel Chemistry 75
Ariel Biology 80
Ricky Physics 95
Ricky Sports 55
Ricky English 80
Jacob France 85
Jacob Chemistry 95

Assuming each student will have different class and the percentage is vs name column. Basically % score to Name is for each student (example, Ariel %Math is 85/(total score in all of her class) to get results as below and so on for each student name.

Name Class Score %Score to Name
Ariel Math 85 28%
Ariel Physics 60 20%
Ariel Chemistry 75 25%
Ariel Biology 80 27%
Ricky Physics 95 41%
Ricky Sports 55 24%
Ricky English 80 35%
Jacob France 85 47%
Jacob Chemistry 95 53%

please have a look at the attached worfklow.

I could create the percentage value only as string ins the â€śPercentage to name columnâ€ť, it is fine for presentation and visualisation.

For further calculation in your workflow you can use the decimal values in column: â€ś%Score to Nameâ€ť.

Roland

Percentage.knar.knwf (39.1 KB)

3 Likes

rolandâ€™s solution looks just fine. You should change the groupby aggregation column from â€śClassâ€ť to â€śNameâ€ť. Besides, I would always change the format of a field in the output file. Within KNIME you can use Right-click â€śAvailable rendersâ€ť (table view on the column header) â†’ â€śPercentageâ€ť.

My workflow looks like this (identical to rolandâ€™s approach)â€¦

br
Tommy

4 Likes

Thanks @rolandnemeth & @tommy for the help

It works perfectly!

1 Like

As far as i can remember the math formula node was also able to calculate the column sum so you might be able to calculate the result with only one node (canâ€™t access KNIME to test right now)
br

Yes, the Math Formula Node can do several column operations, but not group-wise. So thereâ€™s no way around the GroupBy-Joiner combo.
Guten Rutsch, T

2 Likes

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