# Countif Function and Percentage together.

I need support in calculating the % of negative values in a column. I can see the Count Category under the Node: String Manipulation. Though, it counts only Characters not the numbers. Therefore, if anyone can guide me on this query. Thanks.

hi,
Add a â€śrule engineâ€ť node with and create a column â€śisnegativeâ€ť something.
\$yourcolumn\$ < 0 => 1
TRUE = 0

Then add a â€śmath nodeâ€ť with col_sum(â€śisnegativeâ€ť)/rowcount

1 Like

Thanks Andi, this solution is working. Though with this solution I can see the Percentage in each row. Its not showing me the % separately in a single cell. The way we can do it in MS Excel.

Yeah, you can just add a row filter and select the first row only.
As an alternative and in my opinion more elegant solution would be:
add a â€śgroup byâ€ť node after the rule engine and let calculate the â€śsumâ€ť and â€ścountâ€ť of the â€śisnegativeâ€ť column. Use a math node to calculate the percentage

1 Like

Another option might be the usage of the node Extract Table Dimension â€” NodePit This node will give you as one value the row count of a table.

First apply a row filter to get the negative values only. Then get the row count of the original table (your 100%) and the row count of the negative values table.
Using the rowcount you can then calculate the desired value.

2 Likes

Thanks Andi, this option worked well.

1 Like

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