Identify last row of table and edit one column value

Hey there,

i am currently trying to identify the last row of a table and change one value within one column.
I am trying this to set a flag in the column “last_row” as true. I need to identify each last row for one ID (already sorted by ID’s and set via viariable loop into seperate tables for each ID) to use later on only these last rows for my analysis (goal is to filter on the column last_row for true and false, as neede in the analysis).

I already searched within the forum and via google, but couln’d find any fitting answer.

Thank you in advance!

Hi @Boioing,

A simple approach would be to use a Row Splitter node and separate the last row from the rest. You can then modify it and use a Concatenate node to concatenate it with the rest of table.

Cheers,
Simon

Is there a simple way to filter the last ‘n’ rows in the Row Filter / Row Splitter nodes?

It would be great if either the Include rows by number option for example allowed negative indices to mean ‘from the end’ (as they work in Python for e.g. string splicing etc) - I just tried it, and at the moment the node just silently converts a -ve start index to ‘1’ (without warning!)

Steve

Hi there!

@Boioing Why not use GroupBy node with aggregation Last on your original data set? This way you will have all last rows per ID. No need for variable loop, dividing data set into multiple data sets and flagging. If I got it right :slight_smile:

@Vernalis This could be a useful feature. In the meantime sort it in opposite way and then filter normally :slight_smile:

Br,
Ivan

2 Likes

@Vernalis You can add the cut off limit with a math node like so.

image

Then use the Rule-based Row Filter node to select the lines.

image

But this all feels so complicated.

1 Like

one could use a Rule-Based Row Filter with the following Rule:
$$ROWINDEX$$ = $$ROWCOUNT$$ => TRUE

4 Likes