I should've mentioned I tried setting default values. Perhaps I'm doing something wrong there. Please fid report XML attached.
Original Message:
Sent: Thu January 22, 2026 11:54 AM
From: Dinesh K. Dhiman
Subject: Dynamic Date Filters
Hi Jeremy,
This can be handled using default values.
You can also use prompt macro for passing the default values.
Please feel free to share the report xml if problem persist, I will be happy to help.
Thanks
DD
------------------------------
Dinesh K. Dhiman
Technical Product Manager, Cognos Analytics Offering Management
------------------------------
Original Message:
Sent: Thu January 22, 2026 09:41 AM
From: Jeremy Aude
Subject: Dynamic Date Filters
Hi Dinesh,
I hope you are well.
I like using these expressions to achieve some relative date filters while also allowing the user to enter a custom range if desired. However, I've noticed that when running the report again (reprompting), we are always presented with another prompt for ?pStartDate? and ?pEndDate?. For instance, I run the report and select a relative month-to-date. Then in the results I click the run button to return to the prompt page. I select another option (either a different relative range or a different, non-date filter), click Finish on the prompt page and then I get a generic page for requiring I select values for ?pStartDate? and ?pEndDate?.
Have you experienced this and found a workaround?
This is what my filter expression looks like:
( ( ?pDateType? = 'CM') and ( [Creation Date] between _first_of_month ( current_date ) and _last_of_month ( current_date ) ) )
or
( ( ?pDateType? = 'MTD') and ( [Creation Date] between _first_of_month ( current_date ) and current_date ) )
or
( ( ?pDateType? = 'PM') and ( [Creation Date] between _first_of_month ( _add_months ( current_date, -1 ) ) and _last_of_month ( _add_months ( current_date, -1 ) ) ) )
or
( ( ?pDateType? = 'CY') and ( [Creation Date] between _add_days ( current_date, ( ( _day_of_year ( current_date ) -1 ) * -1 ) ) and cast ( extract ( year, current_date ) || '-12' || '-31', date ) ) )
or
( ( ?pDateType? = 'CD') and ( [Creation Date] = current_date ) )
or
( ( ?pDateType? = 'PD') and ( [Creation Date] = _add_days ( current_date, -1 ) ) )
or
( ( ?pDateType? = 'Custom') and ( [Creation Date] between ?pFromDate? and ?pToDate? ) )
Thanks,
Jeremy
------------------------------
Jeremy Aude
Original Message:
Sent: Thu July 02, 2020 11:20 AM
From: Dinesh K. Dhiman
Subject: Dynamic Date Filters
Hello Dean,
Prompt options are not available with Dashboard utility (as of now).
However, you can still explore the options using given Filters and based conditions in Dashboards.
------------------------------
Dinesh K. Dhiman
BI Architect,
IBM Data and AI Experts Labs | India Software Lab Services
Original Message:
Sent: Thu July 02, 2020 10:57 AM
From: Pegasus Administrator
Subject: Dynamic Date Filters
Thanks Dinesh. Is there any possibility the same functionality can be added to a dashboard instead of a report?
------------------------------
Dean
Original Message:
Sent: Thu July 02, 2020 10:42 AM
From: Dinesh K. Dhiman
Subject: Dynamic Date Filters
There can be multiple ways of implementing this, here's one of the option :-
Your YTD and MTD Filters can be defined at Model/Data Module level as follows:-
a) YTD Filter
Expression - [YourDateField] between _add_days(current_date,-1*_day_of_year (current_date)+1) and current_date
b) MTD Filter
Expression - [YourDateField] between _first_of_month (current_date) and current_date
You can add a Radio button selection for users to select their desired option.
Let's say this is pDateMode prompt on Report page with options as
- Default Date Filters - Hide "From Date" & "To Date" prompt selections
- Custom Date Filters - Show "From Date" & "To Date" prompt selections
Filter condition in each of the Query subject would say: -
(?pDateMode?='Default Date Filters' and [YTD Filter]) OR (?pDateMode?='Custom Date Filters' and [YourDateField] between ?pStartDate? and ?pEndDate? )
Basically you can play around with your filter conditions using aforesaid options in hand.
Hope this helps.
------------------------------
Dinesh K. Dhiman
BI Architect,
IBM Data and AI Experts Labs | India Software Lab Services