How to subtract current value from previous value in a column

annuvere
Member Posts: 4
I have a column that i need to subtract a current value from the previous value and save the result on another column. The value is incrementing instead of decrementing.
Here is the image of what i want to achieve

This is my code:
Here is the image of what i want to achieve

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;
0
Answers
-
I don't know if I get what you want.
DailyReturn:=0;
TempFundPriceNew.RESET;
//maybe some item range -> TempFundPriceNew.SETRANGE("Item No", SelectedItem);
TempFundPriceNew.SETRANGE(TempFundPriceNew.Date, StartDate, EndDate);
IF TempFundPriceNew.FINDSET THEN BEGIN
REPEAT
DailyReturn += "Temp Fund Price New"."Bid Price LCY";
//would be better to create a function
SetNewPrice.RESET;
SetNewPrice.SETRANGE("Item No", SelectedItem);
SetNewPrice.SETRANGE(SetNewPrice.Date,"Temp Fund Price New".Date);
IF (SetNewPrice.FINDFIRST) THEN BEGIN
SetNewPrice.DailyReturn:=DailyReturn;
SetNewPrice.MODIFY();
END;
UNTIL TempFundPriceNew.NEXT = 0;
END;1 -
[Topic moved from 'Navision Attain' forum to 'NAV/Navision Classic Client' forum]
Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
For the sake of sql, when use repeat always use FINDSET
When you modify record just use FINDSET(true,false)0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions