Is there a way to iterate an If statement on the last row of a table?we have a table that is created from a db query. We use the date/time stamps in this table to determine start/stop times for more detailed queries. The problem we are having is that sometimes the date/time stamps at the end of the table are not a 'matched' set. In this table, we have created formula columns that help us identify which dates are on which row. We know the pattern that we need to have: the last two rows in X_3 need to end in 1 then 0.
If(dt:X_3[NRow(dt)-1] == 0, dt<< deleteRows(NRow(dt)));
If(dt:X_3[NRow(dt)] == 1, dt<< deleteRows(NRow(dt)));
Is there a way to iterate only on the last row until the table has the desired structure?
Re: Is there a way to iterate an If statement on the last row of a table?In the end, what I needed looked like this
While( continue,
If( dt:X_3[N Row( dt ) - 1] == 0,
dt << deleteRows( N Row( dt ) ),
continue = 0
)
);
Thanks
Re: Is there a way to iterate an If statement on the last row of a table?Just to close the loop on this post for now, @zetunedav realized we actually work for the same company (and know each other
), so we're going to resolve this in a meeting.
Re: Is there a way to iterate an If statement on the last row of a table?@cwillden Thanks for the input. I'm more interested in the second option. However, the number of rows that need to be trimmed off the bottom varies. I was hoping I could evaluate the last row, delete it and re-valuate the If statement on the 'new' last row in a loop until the Else becomes true.
Re: Is there a way to iterate an If statement on the last row of a table?I would be careful deleting rows from within a formula column. Every time the formula is re-evaluated, it will chop off the last row. However you can create a logical condition for the last row in a column formula using something like this:
If( Row() == N Row(Current Data Table()), do this, do that);
For your situation, I would run a separate script, not as in a formula column, to cut off the last row so you don't leave that code as a permanent feature of your resulting data table. In that case, the script would pretty much look like what you have.