Calculate percentage after Value counter

Hello there,

How can I calculate the percentage of each row ID? What node should I be using next?

For example: Hotel availability % = 95/(420+316+213+123+95) *100%

My workflow is relatively simple as follows:

Sincerely,

Hi @doan_lai and welcome to the Knime Community.

You can do this percentage via a Math Formula node.

EDIT: Hereâ€™s a bit more details:

`\$count\$ * 100 / COL_SUM(\$count\$)`

Results:

3 Likes

Welcome to the forum @doan_lai.

If you want to keep this approach, then as @bruno29a pointed out, you can use the Math Formula node with the expression: `\$count\$/COL_SUM(\$count\$)*100`

Iâ€™d recommend looking at the GroupBy node, as you may be able to combine all these steps into a single node. Youâ€™d group by the identifying text column and aggregate on another column using Percent.

3 Likes

Thank you all kindly! I have been able to accomplish what I set out to do.

Now, Iâ€™ve been trying to connect it with Bar Chart to express the data visually. However, it cannot be done because â€śNo column in spec compatible to â€śNominalValueâ€ťâ€ť. I think I need to have another step to convert the output data in Math Formula node into Nominal Value.

How may I express the Percentage into Barchart from Math Formula node? Thank you in advance!

I donâ€™t think that the percentage column is the problem.

I think that the problem is that youâ€™re using strings as RowIDs to capture the description of each row, instead of using a separate dedicated column for this purpose.

The Bar Chart node needs a category column, and you donâ€™t seem to have one. Therefore, youâ€™ll need to make one. You can try using the RowID node to create a category column from the existing RowIDs.

Using the GroupBy node to calculate the percentages mightâ€™ve allowed you to avoid this issue.

1 Like

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