Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

More periods in sales statistics report 112

(0) ShareShare
ReportReport
Posted on by

The standard sales statistics report when selected the date 01-01-2015 ect. have a column for 'before', '01-01-15 - 31-01-15', '01-02-15 - 28-01-15', '01-03-15 - 31-03-15', 'After'. 

I want to make it continue to show all the following 12 months. I know you can extend the periods range so it shows for a period of 3 months, but thats not what i want. 

I have tired to change the following code and inserting the fields and the layout, but i had trouble running the report because of a error.

OnPreReport()
CustFilter := Customer.GETFILTERS; FOR i := 2 TO 4 DO PeriodStartDate[i + 1] := CALCDATE(PeriodLength,PeriodStartDate[i]); PeriodStartDate[6] := 31129999D;


How should i change the code in report 112 to be able to show more date periods than the 3 from standard?

Thanks in advance.

*This post is locked for comments

  • Community Member Profile Picture
    on at
    RE: More periods in sales statistics report 112

    Thanks alot Vishal! That was just what i needed to make it work.

  • Verified answer
    Community Member Profile Picture
    on at
    RE: More periods in sales statistics report 112

    Have you increased the Dimensions for all the fields....

    Currently it is 5. You should increase the same, as per your need.

    4628.1.JPG

  • Community Member Profile Picture
    on at
    RE: More periods in sales statistics report 112

    Hi Vishal,

    I get the error "Index out of bounds."

    What i have tried to do is changeing the code in OnPreReport.

    Changing the PeriodStartDate[6] to [14].

    OnAfterGetRecord() trigger - to filter more values. I have changed it from 1-5 to 1-13. 

    So it would look like this

    OnPreReport()
    CustFilter := Customer.GETFILTERS;
    FOR i := 2 TO 10 DO
      PeriodStartDate[i + 1] := CALCDATE(PeriodLength,PeriodStartDate[i]);
    PeriodStartDate[14] := 31129999D;
    
    OnPostReport()
    
    Customer - OnPreDataItem()
    CurrReport.CREATETOTALS(
      CustSalesLCY,CustProfitLCY,AdjmtCostLCY,AdjCustProfitLCY,
      CustInvDiscAmountLCY,CustPaymentDiscLCY,CustPaymentDiscTolLCY,CustPaymentTolLCY);
    
    Customer - OnAfterGetRecord()
    PrintCust := FALSE;
    FOR i := 2 TO 13 DO BEGIN
    ...

    Then in the dataset designer i have made more fields - periodStartDate6-12 and same with other fields.

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: More periods in sales statistics report 112

    Hi,

    You need to change the code in OnPreReport trigger to define the right periodstartdate

    and

    Customer - OnAfterGetRecord() trigger - to filter the right values.  As of now, it is generating for 5 arrays. You can run the For loop as needed.

    Increase the dimensions array for all the fields.

    What is the error that you are getting currently?

    Hope this helps.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Microsoft Dynamics NAV (Archived)

#1
Sohail Ahmed Profile Picture

Sohail Ahmed 2

#1
mmv Profile Picture

mmv 2

#1
Amol Salvi Profile Picture

Amol Salvi 2

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans