Author Topic: 1 yr prior data  (Read 552 times)

Offline coghost

  • Full Member
  • ***
  • Posts: 6
  • Forum Citizenship: +0/-0
1 yr prior data
« on: 25 Mar 2008 05:23:20 pm »
Hi,

I have a list report with PO Date col. The purpose is, the user should select a date.Based on this selected date all data for PO Date between (1 yr prior to date selected by user )and (date selected by user shud be displayed).
Eg- if the date selected by user is 20071024(yyyymmdd) , then data for PO Date between 20061024 and 20071024 shud be displayed.
Try1- i have a value propmt with parameter p_date on PO Date. I have added a data item with calc in expression editor as  _add_years((cast(?p_date?),date),-1) .
If I select date as 20070124, it is displaying data where PO Date is 20060124 only.
TRY2-I also tried adding filter on PO Date as PO DATE between_add_years((cast(?p_date?),date),-1) and ?(p_date?).But report is not getting validated..
How do i get all 12 months prior data according to the date selected by the user?

Offline jethro89

  • Full Member
  • ***
  • Posts: 13
  • Forum Citizenship: +0/-0
Re: 1 yr prior data
« Reply #1 on: 19 Apr 2008 12:58:01 am »
I would substring the date field and subtract from the year, and do a to_date on it (if you're in oracle). to_date(concat(to_char(to_number(substr(?p_date?,1,4)-1),'YYYY'),substr(?p_date?,5,4)),'YYYYMMDD')

Might be convoluted, but something like this worked for us a while back. We changed our fact table a bit to make it more eligant.

Offline almeids

  • Statesman
  • ******
  • Posts: 304
  • Forum Citizenship: +15/-2
Re: 1 yr prior data
« Reply #2 on: 21 Apr 2008 07:47:43 pm »
This filter...

[gosales_goretailers].[Orders].[Order date] between _add_years(?pdate?,-1) and ?pdate?

...works fine with the GOSAR data, so the issue is probably with the formatting/casting of your value prompt parameter.  Using a date prompt and eliminating the cast should help if that's an option.  If not, manipulate your string value and get the database to do the work as jethro89 suggests.