Divide by total of rows

Hello there,

I am super new to Knime. I have following table:

Destination, Dispatcher, NumberOfEvents, Price
Germany,     D1,         15,             150.0
Germany,     D5,         20,             200.0
Germany,     DWrong,     20,             200.0
Spain,       D1,          5,             50.0
Spain,       D4,         15,             150.0

when there is an entry with Dispatcher equals DWrong, I would also like to create another entry with Dispatcher equals “Error” (and the other values same as “DWrong”). E.g.:

Germany, Error, 20, 200.0

But the entry should be created only when the NumberOfEvents in “DWrong” is bigger than 1% of the total NumberOfEvents for that same Destination.

The pseudo code would be something like this:

loop (Destination) // Germany, Spain
{
    loop () {    
        TotalNumberOfEvents += NumberOfEvents;
    }

    loop () {
        if (Dispatcher == "DWrong") {
            if (NumberOfEvents > (TotalNumberOfEvents * 0.01) ) {
                addRow(Destinaction, "Error", NumberOfEvents, Price);
            }
        }
    }    
}

How can I do something like this with Knime ?

Thanks in advance,

Hi @javier,

I created an example workflow and attached it below.

conditional_rows.knwf (31.6 KB)

Is that what you are looking for?

Cheers,
David

3 Likes

Whaaaat ??? This is amazing, so fast and it’s exactly what I needed. This community is awesome.

Ok the result is what I need. Now going through the units to see what they do. I think I grasp the whole concept, this helps me a lot to understand how the software works.

Million thanks…
Javier

3 Likes

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