COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: NiceCube on 23 Nov 2015 06:11:48 AM

Title: Date Prompts on a report
Post by: NiceCube on 23 Nov 2015 06:11:48 AM
Hi,

I've set up a report where the startdate and enddate prompts are on the report itself, as opposed to a prompt page and have added javascript to set the dates (today -15 and today -1).

I've also set up an optional filter to display data between ?startdate? and ?enddate?

It all works fine, however, I can't work out how to return data between those two dates when the report loads initially. If that can't be done, how to filter the initial report to show the last 14 days data.

Any help greatly appreciated.
Title: Re: Date Prompts on a report
Post by: bdbits on 23 Nov 2015 10:02:00 AM
The report is running before your prompts get set by your javascript. Set your filter such that if prompts are null (i.e. have not yet been set), it will use your desired start/end dates.
Title: Re: Date Prompts on a report
Post by: NiceCube on 24 Nov 2015 06:14:48 AM
Thanks for your feedback bdbits.  I altered my filter to be the following, however it made no difference.

cast([Reporting View].[Outbound Summary].[Date], date) >=
case when ?pStartDate? is null then _add_days(current_date, -15) else ?pStartDate? end and
cast([Reporting View].[Outbound Summary].[Date], date) <=
case when ?pEndDate? is null then current_date else ?pEndDate? end

I'll keep chugging away..... :)
Title: Re: Date Prompts on a report
Post by: BigChris on 24 Nov 2015 06:42:14 AM
Is this any use to you?

http://cognostips.weebly.com/blog/date-prompts (http://cognostips.weebly.com/blog/date-prompts)

You might be able to tweak the logic to get your fifteen days, and set a default value for the prompt for when the report runs.
Title: Re: Date Prompts on a report
Post by: NiceCube on 24 Nov 2015 09:55:05 AM
Cheers BC - however, I'm trying to get the prompts working on the report (as opposed to a prompt page).  Pulling my hair out with this one, but I'll get there (eventually). :)
Title: Re: Date Prompts on a report
Post by: BigChris on 24 Nov 2015 10:06:43 AM
What I was thinking was you could create an extra option in the prompt for 15 days and set that as the default option. I don't know if the report would run and pick that option up so that you get 15 days worth...I guess it might throw up those prompts. Anyway, thought it was worth sharing in case it was a possibility.
Title: Re: Date Prompts on a report
Post by: NiceCube on 24 Nov 2015 10:31:57 AM
Yes, I see your train of thought there.  I'll have a dabble and let you know.