Hello all, I'm new to both expression and python scripts but learning a lot recently. I'm currently trying to make a table that shows data, I have most of it down, but the last function is giving me issues.
I have multiple buttons that are scripted to show production values for certain periods of time. This I have working, but the story is a little more complicated. I'm using machine tags that have grand totals of all time, so I scripted the values in my table to begin at zero and show just the amount produced during that time frame. I've done this using a "for" loop on my first dataset and displaying the new dataset in the table.
Now I am trying to script a button that displays how much was produced over the last 30 days, and displaying not the incremental values, but each day's individual total. I first thought that this would be easy, just keep the same loop structure and for each row's base value (the grand total), I would subtract the last row's value from it. However, I have no clue how to reference "the previous row" in the loop!
The base value is easy. Tag = dataset.getValueAt(row, 1)
I thought it could be something like PreviousValue = dataset.getValueAt(row - 1, 1) or dataset.getValueAt(dataset.row - 1, 1) but this does not seem to exist. The closest thing I tried was dataset.getValueAt(dataset.rowCount - 1, 1) but this obviously references the value in the second-to-last row rather than the previous row of each iteration of the loop.
How could I do that? Is there a way to reference the previous row in a loop? There has to be, right?
Thanks all