I have a data table that has time increments from 0-->n for each step for a series of several steps.
Wondering if there's a bkm to script to make each step time start at the end time of the previous step.
aka:
currently: step1, time = 0--> 7, step2, time = 0-->12
goal: step1, time=0-->7, step2, time7-->19
Advice?
Columns:
sensor Label | Value | time | Step
Here is a sample data table and a simple script that will adjust the time when the step changes. The script first displays the data table for 10 seconds, so you can see what the original table looks like, and then it goes ahead and runs the little script to adjust the time values.
Names Default To Here( 1 );
dt = New Table( "example",
Add Rows( 42 ),
New Column( "time",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values(
[0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 0, 1,
2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
)
),
New Column( "Step",
Character,
"Nominal",
Set Values(
{"Step1", "Step1", "Step1", "Step1", "Step1", "Step1", "Step1", "Step1",
"Step2", "Step2", "Step2", "Step2", "Step2", "Step2", "Step2", "Step2",
"Step2", "Step2", "Step2", "Step2", "Step2", "Step3", "Step3", "Step3",
"Step3", "Step3", "Step3", "Step3", "Step3", "Step3", "Step3", "Step3",
"Step3", "Step3", "Step3", "Step3", "Step3", "Step3", "Step3", "Step3",
"Step3", "Step3"}
)
)
);
wait(10);
For Each Row(
If( Row() == 1,
adder = 0,
If( Lag( :step ) != :step,
adder = :time[Row() - 1]
)
);
:time = :time + adder;
);this works great! I am noticing just a small issue. at the time increment where the step changes, it is repeating the time value, rather than incrementing. I'm still trying to understand the LAG function. Any tips?

Finally, any tips for adding in x-axis markers into the script to label the blocks of the trace?
I can create new columns for local min/max based on step#, but not sure how to script that into an axis label.


Concerning your first issue, your requirement for the increment between steps was
goal: step1, time=0-->7, step2, time7-->19
Note, the time value was the same for the last value in the first step, as well as the first time in the second step.
If you want to increment between the steps, just change the adder value to whatever the additional increment is desired
adder = :time[Row() - 1] + 1
I do not understand what you are asking for when you say "adding in x-axis markers into the script to label the blocks of the trace".
Finally, All of the functions, such as Lag() are documented in the Scripting Index, available under the Help pull down menu.