There could be easier was to do the formula depending on if the:
- Data is sorted
- If 35mph appears only once per repeat
- If 35mph has always smallest Time value
Because that information was not given or I did understand something incorrectly I went with a bit more complicated formula:
Names Default To Here(1);
dt = New Table("Untitled",
Add Rows(12),
Compress File When Saved(1),
New Column("Repeat",
Numeric,
"Continuous",
Format("Best", 12),
Set Values([1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4])
),
New Column("Speed",
Numeric,
"Continuous",
Format("Best", 12),
Set Values([35, 35, 70, 35, 40, 70, 35, 36, 70, 60, 35, 36])
),
New Column("Time",
Numeric,
"Continuous",
Format("Best", 12),
Set Values([1, 2, 3, 1.1, 2, 3, 1.2, 2, 3, 1, 2, 3])
)
);
dt << New Column("Adjusted Time",
Numeric,
"Continuous",
Formula(
If(Row() == 1,
//Find rows with speed of 35
speedRows = Loc(:Speed << get as matrix, 35);
//get repeats for 35 rows
repeats = :Repeat[SpeedRows];
);
//time for first 35mph for current rows repeat
curTime = :Time[Loc(repeats, :Repeat)[1]]; //adjusted time
:Time - curTime;
)
);
-Jarmo