Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics GP (Archived)

YTD sales showing last year's data...

Posted on by 170

When I run an SSRS report that has YTD sales, it shows not only this years data, but the second half of last year as well. I figure this is happening because we previously had fiscal years that started July 1st. We changed at the beginning of 2012 to a calendar year. I looked through the SQL and couldn't see anything going after fiscal year data. Is it OK to post the SQL code here?

*This post is locked for comments

  • Steve P Profile Picture
    Steve P 170 on at
    Re: YTD sales showing last year's data...

    I'm going through Mark Polino's excel sheet of tables and cannot find a RM Transaction Table. Would it be the "RM Realtime Posting File" or RM20102?

  • Steve P Profile Picture
    Steve P 170 on at
    Re: YTD sales showing last year's data...

    OK, here's the first:

    --declare @MBeg as datetime = '2017-04-01'
    --declare @YBeg as datetime = '2016-07-01'
    --declare @YEnd as datetime = '2017-04-30'

    select c.CUSTNMBR, c.CUSTNAME, c.ITEMNMBR, c.ITEMDESC
    , sum(c.M_QUANTITY) as M_QUANTITY
    , sum(c.M_XTNDPRCE) as M_XTNDPRCE
    , sum(c.Y_QUANTITY) as Y_QUANTITY
    , sum(c.Y_XTNDPRCE) as Y_XTNDPRCE 
    from
    (
    select b.DOCDATE, b.CUSTNMBR, b.CUSTNAME, b.ITEMNMBR, b.ITEMDESC, b.ITMCLSCD, b.Y_XTNDPRCE, b.Y_QUANTITY
    , case 
     when b.DOCDATE between @MBeg and @YEnd
     then b.Y_XTNDPRCE
     else 0
    end as M_XTNDPRCE 
    , case 
     when b.DOCDATE between @MBeg and @YEnd
     then b.Y_QUANTITY
     else 0
    end as M_QUANTITY    
    from
    (
    select a.SOPTYPE, a.SOPNUMBE, a.DOCDATE, a.CUSTNMBR, d.CUSTNAME, b.ITEMNMBR, c.ITEMDESC, c.ITMCLSCD
    , case
     when a.SOPTYPE = 3 then b.XTNDPRCE
     when a.SOPTYPE = 4 then b.XTNDPRCE * -1
     else 0
    end as Y_XTNDPRCE
    , case
     when a.SOPTYPE = 3 then b.QUANTITY
     when a.SOPTYPE = 4 then b.QUANTITY * -1
     else 0
    end as Y_QUANTITY
    from SOP30200 a
    join SOP30300 b on b.SOPTYPE = a.SOPTYPE and b.SOPNUMBE = a.SOPNUMBE
    join IV00101 c on c.ITEMNMBR = b.ITEMNMBR
    join RM00101 d on d.CUSTNMBR = a.CUSTNMBR
    where a.SOPTYPE in (3,4)
    and a.VOIDSTTS = 0
    and a.DOCDATE between @YBeg and @YEnd
    ) b
    ) c
    where c.ITMCLSCD in (@ItemClass)
    group by c.CUSTNMBR, c.CUSTNAME, c.ITEMNMBR, c.ITEMDESC
    order by c.CUSTNAME, c.ITEMNMBR

    The second one is:

    select year(getdate()) as YEAR1
    union all
    select YEAR1 from sy40101
    order by YEAR1 desc

    The third one is:

    select distinct rtrim(ITMCLSCD) as ITMCLSCD from IV00101
    order by ITMCLSCD

    On the report itself, the qty ytd is "=Fields!Y_QUANTITY.Value" the sales ytd is "=Fields!Y_XTNDPRCE.Value"

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    Re: YTD sales showing last year's data...

    Hi Steve - yes - post the code here.

    If you are getting your data from the Sales YTD field in the Debtor Summary table - this could be your problem. You may not have run a Sales Year end at the end of the last calendar year when you changed over. If so this field will be collecting data from last year and this new year.

    There is really no simple solution to this - you could maybe look at calculating the sales for each year for each customer (from the RM Posted transactions tables) and updating this summary table...or changing the SSRS report to calculate the sales to date based on the RM Posted Transaction tables.

    Ian.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans