简体   繁体   中英

Scheduling a report that contains a value prompt with dates

I have a Cognos report, which contains a prompt page with a Date Valid prompt. This is a value prompt, not a date prompt.

I need to schedule this report so when the schedule is suppose to run, the last day of the previous month from this prompt will be automatically selected.

Right know if I create a schedule and define my prompt values, I select the last day of the previous month. But then the scheduled report always runs with this date which has been set, even when i schedule it to run next month.

I would like the report to automatically selected the last day of the previous month from this value prompt when the report is scheduled (for example I schedule this report to run next month Monday in September and I need it to select 31st of August automatically).

The solution found online includes macro prompt, or creating two values/options for the date prompt - one for scheduling (which will automatically select last available date according to the schedule date) and one for ad-hoc report run (select your desired date from the prompt).

Any help how/where to use the macro prompt would be much apreciated.

Thank you

Step 1) On your main report query create a data item (go to the query, to the tool box and drag query calculation over to you data items)

Name it something like, Target Date

and the expression should be:

add_days(current_date,-1) 

Step 2) Add another value prompt with static values of Y and N, name the parameter something like ScheduleDate

Step 3) Change the value prompt for your date, set usage optional

Step 4) For your existing filter based on your existing value prompt ie

[Invoice Date] = ?SomeDate?

Change this filter for your main report query to

(?ScheduleDate? = 'N' and [Invoice Date] = ?SomeDate?) OR
(?ScheduleDate? = 'Y' and [Invoice Date] = [Target Date])

If you ran on Dec 1st, it would use Nov 31st

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM