How to subtract current value from previous value in a column using C/AL code

Viewed 10

I have a column that I need to subtract a current value from the previous value in Bid Price LCY column and save the result on another column called Daily Return(Offer). The value is incrementing instead of decrementing in Daily Return(Offer) column.

Here is the image of what I am getting enter image description here

Here is my code:

LastDailyReturn := 0;
TempFundPriceNew.RESET;
TempFundPriceNew.SETCURRENTKEY("Fund No.",Date);
TempFundPriceNew.SETRANGE(TempFundPriceNew."Fund No.","Temp Fund Price New"."Fund No.");
TempFundPriceNew.SETRANGE(TempFundPriceNew.Date,StartDate,"Temp Fund Price New".Date);
IF TempFundPriceNew.FINDFIRST THEN REPEAT
   LastDailyReturn += "Temp Fund Price New"."Bid Price LCY";
UNTIL TempFundPriceNew.NEXT = 0;
0 Answers
Related