Crystal Reports 2011 - AR_InvoiceHistoryHeader 24 Months

Hi

on sage 100 standard 2017

I am trying to pull 2 years with of data from our AR_InvoiceHistoryHeader/Detail records.

The report i am trying to write will compare 2 years worth of data.  so if I put in a date like May 31, 2018 it will compare may 2018/may 2017, april 2018/2917, march2018/2017 etc 12 months comparison to the previous years data.

I have buckets building my data, and the first 5 months work perfectly  may,april,march,feb, jan work comparing both years, when it gets to dec 2017 it pulls that data but for some reason it will not pull dec 2016 data. 

I have tried putting in no record select criteria in the report so it goes thru the entire file but it still will not pull.  i have written a report for dec 2016 and have data populating from that table so i know i have data.

i have tried using datediff("m",{AR_InvoiceHistoryHeader.InvoiceDate},{?PromptFromDAte}) in 0 to 23  and that also only pulls the first 5 months comparison and only the 6month not the comparison month to this one. the comparison month doesnt pull any data.

does anyone have any thought on what i am doing incorrectly?

  • 0

    Does AR_InvoiceHistoryHeader contain records going back 2 years?

  • 0 in reply to BadgerJerry

    Copy / paste your report selection criteria.  I usually write a "StartDate" formula and put the date calculation logic there, so I can drag the formula into the report for troubleshooting.

  • 0

    Hey, 

    yes there are records in there going back 3 years.

    Here is my select criteria:

    {AR_InvoiceHistoryHeader.WarehouseCode} = "000" and
    {AR_InvoiceHistoryHeader.CustomerNo} in ["A440", "C601", "C601PR", "C601RC", "H013", "O004", "T002", "W001C"] and
    {CI_Item.ProductType} = "F" and
    datediff("m",{AR_InvoiceHistoryHeader.InvoiceDate},{?PromptFromDAte}) in 0 to 23 and
    UpperCase({CI_Item.ItemCode}) in UpperCase({?FROM ITEM}) to UpperCase({?TO ITEM})

    Here is me building my bucket for that previous year "@Month6M-1"

    if month({?PromptFromDAte})-5 = month({AR_InvoiceHistoryHeader.InvoiceDate}) and year({?PromptFromDAte})-1 = (year({AR_InvoiceHistoryHeader.InvoiceDate})) and {AR_InvoiceHistoryHeader.CustomerNo} = "A440" then "AMON6-1"

    Here is my adding to my bucket "6MQtyAMON-1"

    IF {@Month6M-1} = "AMON6-1" then {AR_InvoiceHistoryDetail.QuantityShipped}

    then i just sum it up and put it on report.   

  • 0 in reply to stircrazy08

    This gets you the start date of the chosen month, two years back.  Simple.

    date(year({?PromptFromDAte})-2,month({?PromptFromDAte}),1)

  • 0 in reply to Kevin M

    ok.  is there a formula or something to make the year -1 or -2.  because when it spans years it will need to check to see if it is 2018 or 2017 to go -1 or -2 years back.  if i run it for dec 2017 it compares 2017 to 2016 with no issues and it populates all buckets fine as every one is -1.  but once it starts spanning 2 different years is where my buckets get thrown off.

  • 0 in reply to stircrazy08

    You don't understand... never calculate each piece of the date individually because that makes things overly complicated.  That result is the start date of the report, two years back.  It doesn't matter whether your date falls in the middle of the year or not.  If your entered date was in Dec. 2017 then that formula result would be Dec. 1, 2015.  If you'd actually want to start on Jan. 1 2016, do this:

    DateAdd ("m", 1, date(year({?PromptFromDAte})-2,month({?PromptFromDAte}),1))

    Then pull invoices dated >= this value.