Options

Factbox showing incorrect YTD total - can this be altered?

VotucVotuc Member Posts: 206
edited 2012-05-25 in NAV Three Tier
Hi.

My client noticed that the YTD on the Sales Orders List page is not actually Year to Date but total to date for the entire history of the customer.

Anyone else have this problem? I can't seem to find any way of changing the fields behind the factbox - is it possible? Thanks.

SalesYTD.jpg

Comments

  • Options
    AntHillMobAntHillMob Member Posts: 79
    Look at the OnAfterGetRecord trigger of page 9802. This calls sets the Date Filter then calls CALCFIELDS. The date filter set does not get ste properly for a YTD figure.
  • Options
    VotucVotuc Member Posts: 206
    AntHillMob wrote:
    Look at the OnAfterGetRecord trigger of page 9802. This calls sets the Date Filter then calls CALCFIELDS. The date filter set does not get ste properly for a YTD figure.


    Thank you!! Ok, so I see:

    SETRANGE("Date Filter",0D,CurrentDate);

    And from the help files I see 0D means "undefined date" --- is there a date formula that means First day of the year? (1-1-20??)
  • Options
    JDVyskaJDVyska Member Posts: 179
    Yeap. I sort of outline some date calculation tricks here, but to talk more directly to what you need:

    First read is that you likely want a line like:
    SETRANGE("Date Filter",CALCDATE('-CY',WORKDATE),WORKDATE);
    
    So, if the user, for whatever reason, does a WORKDATE of, say, March 31 of the previous year, the YTD total in the FactBox will show Jan 1 through March 31 YTD figures for the previous year.

    If you don't want it something the user can goof up with changing the work date, simply swap in TODAY for the two WORKDATE references.
    JEREMY VYSKA
    CEO, Spare Brained Ideas, Göteborg, Sweden
    New (April 2021) Getting Started with Microsoft Dynamics 365 Business Central Book Available: "Your First 20 Hours with Business Central"
  • Options
    redkingredking Member Posts: 34
    edited 2012-05-25
    Hi Jeremy,

    Wondering if you could help me. Our financial year runs 1st April to 31st March.
    When I set the filter up as SETRANGE("Date Filter",CALCDATE('-CY',WORKDATE),WORKDATE);
    I get the YTD from the beginning of the year i.e. 1st January

    Do you know how we can use our financial (fiscal??) year instead?

    I have found this but it makes no sense to me: http://mibuso.com/blogs/alexchow/2009/0 ... mment-2552


    Cheers
    Red
  • Options
    JDVyskaJDVyska Member Posts: 179
    Alex had the same question, then blogged his answer to it.
    http://mibuso.com/blogs/alexchow/2009/0 ... scal-year/

    You can use the above to get the Start/End Dates, then use those to SETRANGE.
    JEREMY VYSKA
    CEO, Spare Brained Ideas, Göteborg, Sweden
    New (April 2021) Getting Started with Microsoft Dynamics 365 Business Central Book Available: "Your First 20 Hours with Business Central"
  • Options
    redkingredking Member Posts: 34
    HI Jeremy,

    We are an end user. We asked our partner to quote for this but they came back with £700 to develop this change. I thought that amount of money was too much so I decided to research myself.
    I too found Alex's blog but I do not understand how to put this together.

    Can you help?
    Thanking you for all help
    Red
  • Options
    davmac1davmac1 Member Posts: 1,283
    You will need to add code to calculate your date range. Since that may not be in your license, maybe you could give your reseller the reference and ask them how much to put the same code in your NAV.
Sign In or Register to comment.