Difference between column A of row 2 and column B of row 1 in a table

I am trying to compare the start incremental value of a row with previous end incremental value

e.g.

sensorid | date | start value | end value
cmid123 | 23 Apr | 32 | 36
cmid124 | 23 Apr | 11 | 26
cmid123 | 24 Apr | 38 | 42
cmid124 | 24 Apr | 26 | 31

Hello Srinivasan,

Do you want to ignore the sensor id? if not could you check the below and see if it helps ?

Cal=
start_value - lag(end_value, 1)
OVER (
PARTITION BY sensorid
ORDER BY date ASC
)

Hope this helps .

Cheers,
Deep

Hi Srinivasan @srinivasan_ab , Deepak @Deep ,

Lag function will help as Deepak mentioned. The correct syntax is given below
lag(sum({end value}),[date ASC],1,[sensorid])
This is assuming that you want to pick the prior reading for the same sensor only.

Regards,
Arun Santhosh
Pr QuickSight SA