I have a column named Bid Price LCY where I need to deduct the current value from the previous value and save the outcome in a different column called Daily Return (Offer). The value in the Daily Return(Offer) column is increasing rather than decreasing.
Here is an example of the picture I'm getting.
This 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;
This is the correct 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";//It will decrement the value instead of increment
UNTIL TempFundPriceNew.NEXT = 0;