Report - Horizontal Columns using arrays

TFCrowther
Member Posts: 35
REPORT USING ARRAYS TO CREATE HORIZONTAL COLUMNS
2 Arrays with Dimension 12:
MonthLabel
SalesMthTotal
** Customer down the left with Sales Total by month along the top **
Good Luck
Toby Crowther
2 Arrays with Dimension 12:
MonthLabel
SalesMthTotal
** Customer down the left with Sales Total by month along the top **
Customer - OnPreDataItem() //MESSAGE(FORMAT(CALCDATE('CM + 1D - 1M',150600D))); //TESTING //MESSAGE(FORMAT(CALCDATE('CM',TODAY))); //TESTING //Header Section insert Textboxes - MonthLabel[1], MonthLabel[2], MonthLabel[3] etc //Prints the Month now ie Jan 06 MonthLabel[1] := FORMAT(TODAY,0,'<Month Text,3> <Year4>'); //Prints each month in descending order ie Dec 05, Nov 05, Oct 05 etc.. FOR x := 2 TO 12 DO BEGIN MthFormula := '-' + FORMAT(x) + 'M'; MonthLabel[x] := FORMAT(CALCDATE(MthFormula,TODAY),0,'<Month Text,3> <Year4>'); END; CurrReport.CREATETOTALS(SalesMthTotal); Customer - OnAfterGetRecord() //Body Section insert Textboxes SalesMthTotal[1], SalesMthTotal[2], SalesMthTotal[3], etc.. CLEAR(SalesMthTotal); StartDate := CALCDATE('CM + 1D - 1M',TODAY); EndDate := CALCDATE('CM',TODAY); FOR x := 1 TO 12 DO BEGIN CustLedEntry.SETRANGE(CustLedEntry."Customer No.",Customer."No."); CustLedEntry.SETFILTER(CustLedEntry."Posting Date",'%1..%2',StartDate,EndDate); IF CustLedEntry.FIND('-') THEN REPEAT SalesMthTotal[x] := SalesMthTotal[x] + CustLedEntry."Sales (LCY)"; UNTIL CustLedEntry.NEXT=0; StartDate := CALCDATE('-1M',StartDate); EndDate := CALCDATE('-1M',EndDate); StartDate := CALCDATE('CM + 1D - 1M',StartDate); EndDate := CALCDATE('CM',EndDate); END;
Good Luck
Toby Crowther
0
Comments
-
Hello onaftergetrecord section can improved for performance with the following code.
FOR x := 1 TO 12 DO BEGIN SETFILTER("Date Filter",'%1..%2',StartDate,EndDate); CALCFIELDS("Sales (LCY)"); SalesMthTotal[x] := "Sales (LCY)"; StartDate := CALCDATE('-1M',StartDate); EndDate := CALCDATE('-1M',EndDate); StartDate := CALCDATE('CM + 1D - 1M',StartDate); EndDate := CALCDATE('CM',EndDate); END;
0 -
I tried this report But I get
Feb 06 for MonthLabel[1]
Dec 05 for MonthLabel[2]
Nov 05 for MonthLabel[3]
so on
What Happend to Jan 06?0 -
I believe the following code is the reason
//Prints the Month now ie Jan 06 MonthLabel[1] := FORMAT(TODAY,0,'<Month Text,3> <Year4>');
Change everywhere where TODAY is used to first day of the year.0 -
I moved my clock ahead - the report does skip the previous month
It's Monthlabel[2] where it goes wrongTFCrowther wrote:MthFormula := '-' + FORMAT(x) + 'M';
MonthLabel[x] := FORMAT(CALCDATE(MthFormula,TODAY),0,'<Month Text,3> <Year4>');
END;MthFormula := MthFormula + '+' +'1M';
I'm sure someone will pop in with a better code.
Where's Kriki the codemaster when you need him 8)
Now i'll go check the monthly totals to see if everything is peachy-keen!
& This drastically increases the reports performanceara3n wrote:Hello onaftergetrecord section can improved for performance with the following code.FOR x := 1 TO 12 DO BEGIN SETFILTER("Date Filter",'%1..%2',StartDate,EndDate); CALCFIELDS("Sales (LCY)"); SalesMthTotal[x] := "Sales (LCY)"; StartDate := CALCDATE('-1M',StartDate); EndDate := CALCDATE('-1M',EndDate); StartDate := CALCDATE('CM + 1D - 1M',StartDate); EndDate := CALCDATE('CM',EndDate); END;
0 -
how to do this for a Form This is really urgent
Considering a form doesnt have CREATETOTALS
i tried addding the code on ONAFTERGETRECORD TRIGGER BUT ITS ](*,)Regards,
GD0 -
do you have form 351?
Another form that calculates using the cust ledger entry is form
10007 "Customer Credit Information"
It's splits into 4 periods but it can be easily changed to 12 months instead.
If i have some time later I'll try it myself. If you don't have that form I renamed it and you and try it yourself here
http://savatage99.googlepages.com/Form5 ... naform.fob
now that I look more into it I think 351 kicks more butt.
let me know if you don't have it.0 -
i m Doing the Same report but i want the user to enter Startdate and EndDate can i get some help0
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