Distance()

GW375
New Member

I am working on a fishing app and need to calculate the distance between two LatLong points. This distance is โ€œby the way the crow fliesโ€ so I know I can use Distance(). I have a simple table called โ€˜Locationโ€™ Here is the AppSheet Columns view of this table.

I want the column DistanceTraveled to be the distance between column [Location] and the [Location] from the previous row.

Within the DistanceTraveled column I used the following DISTANCE() expression in the Auto Compute App formula: Distance([Location], [_THISROW_BEFORE].[Location])

The answer that results is 0.

I know there is likely a simple answer, but I just canโ€™t figure it out. Iโ€™m not a programmer or app builder, but rather a physician learning appsheet to keep my mind off COVID. Thanks!

Solved Solved
0 3 474
1 ACCEPTED SOLUTION

Steve
Platinum 4
Platinum 4

Try:

ANY(
  SELECT(
    Location[Location],
    (
      [_ROWNUMBER]
      = MAX(
        SELECT(
          Location[_ROWNUMBER],
          ([_ROWNUMBER] < [_THISROW].[_ROWNUMBER])
        )
      )
    )
  )
)

View solution in original post

3 REPLIES 3

Steve
Platinum 4
Platinum 4

Try:

ANY(
  SELECT(
    Location[Location],
    (
      [_ROWNUMBER]
      = MAX(
        SELECT(
          Location[_ROWNUMBER],
          ([_ROWNUMBER] < [_THISROW].[_ROWNUMBER])
        )
      )
    )
  )
)

GW375
New Member

Thank you @Steve! Worked well! I initially thought the units for Distance() were meters. But based on my results it seems they are km. Is that correct?

Yes itโ€™s correct.

Top Labels in this Space