rule-based rowfilter check numbers of different rows

Hi,
I’ve a table with many rows. In each row is a number in a column.
I sorted the column.

now the number is 20000, 20000, 20001, 20001 … 7000001, 7000001.

I want to check a list of numbers, if the list has gaps i want to extract the row after the gap.

i mean the following is a good code.
if row > 1 AND row.value = row(-1).value or row.value = row-(-1).value + 1

Anybody knows, how i can write this in rule-based row filter ? Do someone have a better idea ?

Hi,

You can code that in a java snippet or more simply use the LAG Column node.

Best regards

I’m not java coder :frowning: dont know how i can adress a row before

Then use the lag node

Here is an example to put the previous values in from of the cell of interest :
example.knwf (25.3 KB)

the second move does the reverse just in case putting the flowing value

Well,

i understand the solution. But the Problem is, that the solutions are not correct.
Example
Table
A
20000
20000
20001
20001
20003
20003
20004
20004
20006
20006
20009
20009
.

.
.
6999999
6999999
7000001
7000001

One Solution should be

Table
A
20003
20006
20009
7000001

(because the numbers has gaps before)

and another solution should be
20002
20005
20007
20008
7000000

(because this numbers are the gaps)

its possible that a number is not doubled and its possible that gaps are bigger

Well sorry, I really don’t see the point. If I complete the workflow adding the rule to the lag. It gives me that : example3.knwf (22.4 KB)

What should be the result for those datas according to you ?

Best regards

1 Like

Hi @Paddymaster,
please find attached a workflow that also calculates all the numbers in the gaps. Unfortunately it does use a Java Snippet node, but I think you will find the code pretty easy to understand, even as a non-Java-coder. Feel free to ask if you have any questions about it.
Kind regards
Alexander

gaps.knwf (15.5 KB)

2 Likes

thk you both for your solutions.
its very nice; the solutions can help by my workflow.

1 question. Is there no easier solutions as Lag Column ?

Is it not possible to adress a row before the current row in math formula, rule engine, rule-based row filter, and so on ?

Hi,
generally this is unfortunately not possible. Only some scripting nodes, such as the Python Snippet and R Snippet nodes can access the whole table at once, but that only works well if the data is not too large.
Kind regards
Alexander

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