I have the below Data set and and I want to subtract the amount based on the Date column. Date and amount will be keep on changing every time.
Input Data
Run-Date | Amount |
11/22/2023 18:21 | -400 |
11/24/2023 17:45 | -460 |
11/25/2023 16:43 | 580 |
I have the above input data where data is group by on the basis of Run-Date column. Now I want the amount variance between these dates.
22 Nov was the first date, hence 0 is there in the variance column. Total for for 24 Nov is (-460). Variance should be (-460) - (-400) = (-60). Similarly for 25 Nov, total is 580 and variance should be 580 - (-460) = 1040.
Required Result
Run-Date | Amount | Variance |
11/22/2023 18:21 | -400 | 0 |
11/24/2023 17:45 | -460 | -60 |
11/25/2023 16:43 | 580 | 1040 |