Count with condition

I have no clue how to do this:
I need to calculate the consistency of measurment BUT only after first measurment and per each site.
My table and relative results should look like this:

Hi @Paolodam

Something like this should get you moving forward:

Some steps:

Evaluate each site as a group by initiating a Group Loop based on the respective column.

Next task is the determine the start point of each measurement which has to be done dynamically off course. One way to determine is evaluating each row if either parameter 1 or 2 contains a record. If such a record is found, output the RowIndex -1 for later filtering usage.

I opt for a Column Expression using

if (column("Parameter1") != null || column("Parameter2") != null) {
    rowIndex() -1 

From here I can derive that all rows starting from rowIndex = 2 should be accounted for.

With a groupby function, I determine the minimal value of column index since that will act as the starting point to filter from. You can use a groupBy node for this. Convert it to a flow variable thereafter.

Next, connect the table row to flow variable to a row filter node, choose the Include rows by number option, make the RowRangeStart flow variable controlled and check the box for to the end of the table. As such, the first occurrence and onwards will be considered.

Use a Column Aggregator node to count the values of Parameter1 and Parameter2. Count it once with Missing allowed and count it another time with Missing not allowed.

As a last step, sum the counts that were just created and exit the loop.

Final result:


See WF:
Count with Condition.knwf (42.6 KB)

Hope this helps!


Thank you a lot!! It’s an elegant and easy to understand solution eventhough I would have never made it without your hel, since I’m no data analyst and I’m learning by doing. It works perfectly :slight_smile:

1 Like

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