Select and delet specific rows

Hi,

C1 C2
X 1
X 8
X 1
X 10 (X sum)
Y 2
Y 4
Y 6 (Y sum)
Z 3
Z 3 (Z sum)

I want to delete the last rows of each variable that contains the sum of the common previous variables. I think the best way is: creating a loop that will search the last row of each variable, naming it as “Remove”, and then create a new node to delete these rows named “Remove”.

Anybody can help me? Many thanks!

Hi @GabrielFG, welcome to the forum.

There are a few ways you could accomplish this, with varying levels of complexity.

Here are 2 that I can think of:

If the order of the data in the output doesn’t matter:

  1. Use a Group Loop Start node to isolate the rows with a given variable
  2. Sort the data in descending order by the values in C2 (make sure this column has been typed as a number)
  3. Filter out the first row
  4. End the loop

If the order of the data in the output does matter:

  1. Use a Group Loop Start node to isolate the rows with a given variable.
  2. Use a Math Formula node to calculate the number of rows to keep: ROWCOUNT - 1. This means, for example, that if there are 4 rows total, then this calculation would return the number 3, which is how many rows we’d want to keep.
  3. Convert this number into a variable using the Table Row to Variable node
  4. Use a Row Filter or Row Sampling node to keep rows if their row number is less than or equal to this variable
  5. End the loop

These are illustrated here:

3 Likes

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