# Flag Row according to conditional

Hi everyone,

I am quite new to KNIME and this is the logic I would like to apply:

• Sort Column (=Sales information) in descending order
• Loop: Sum Sales looped over so far
if sum sales < 80% of overall sum of column sales --> “xyz” in new column
else next category / nothing

I’m sure that it’s possible with a loop but is there already a node with does it right away maybe? I want to do some further analysis on e.g. products that account for the first 80% of the sales, etc.

Thank you

For the first task use Sorter node

For the secon one Rule Engine or Column Expression nodes.

2 Likes

Hi @swbine

I’am not quite sure if I understood your question well, but see this workflow Flag Row according to conditional.knwf (22.0 KB) . Hope this helps.

gr
Hans

1 Like

Hi,

The Sorter node suggested by @izaychik63.

So you have sales information for each product and those products are in different categories. You have calculated the sum of sales for each category (I guess you’ve done that by using a GroupBy node ) and now you want to label them based on the condition you have mentioned. Is it right?

If yes, I think the best way to do that is to use a Math Formula node:
`if(\$Sum(salesQTY)\$/COL_SUM(\$Sum(salesQTY)\$)<0.8, 1, 0)`

Since the output of the math formula is numeric, you have to manipulate this output and transform it to some other value by using one of the last two nodes suggested by @izaychik63 or even by a String Manipulation node:
`replace(string(\$label\$), "1", "xyz")`

Best,
Armin

2 Likes

sorry for the late reply, we had a long weekend here in Germany

THANK YOU SO MUCH! The workflow suggested by @HansS is exactly what I wanted to achieve.

so @armingrudd, I’d rather wanted to build categories based on the products’ contribution to sales and then analyse some other text columns for only the “Top80%contributors”

So thanks again for your help and have a great week!

Sabine

3 Likes

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