Calculate Duration Between Timestamps

tvinci
New Member

I have a list of stops with timestamps in my app.

I want to calculate the duration of time between the CURRENT stop and the stop RIGHT BEFORE IT.

In my futile attempts to accomplish this I have created a list of relevant timestamps:

Now I want to say, take the current timestamp and calculate the span of time between it and the timestamp right before it.

So if this was a programming language I would start at index 1 instead of index 0 and subtract every timestamp from the timestamp right before it. But as far as I know for loops are not implemented in AppSheet.

How should I go about this? I’ve been struggling with it for a few days.

Thanks AppSheet!

0 9 716
9 REPLIES 9

Rather than working with lists, it would be better to use a VC to compute durations between successive stops. Then, you can construct a list of durations in preferred order if you need to.

I have tried what you’re saying by writing expressions using [_THISROW_BEFORE] and [_THISROW_AFTER] and it did not work.

Can you post your formula?

Assuming you have separate rows for Timestamp, duration for a row needs to be calculated as the difference between current stopand previous stop (except for stop1 which would be 0)

The column headers are missing so I’m not sure what the values are. Why are you using _THISROW_BEFORE? If you need to calculate the duration between consecutive stops you would need to do something like:

[Timestamp]-ANY(SELECT(StopsTable[Timestamp],[Stopnum]=[_THISROW].[Stopnum]-1))

Thank you! What do you mean by stopNum? Here are my column names:


I fixed it! Thank you

Top Labels in this Space