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
Original Message:
Sent: Thu July 02, 2020 07:41 AM
From: Pegasus Administrator
Subject: Dynamic Date Filters
Version: IBM Cognos Analytics 11.1 R6
Hey all, hoping you can assist a new user with the best approach to managing date filters.
Basically, one of the ongoing problems we're facing is how to apply dynamic date filters to the dashboard and individual charts independently. In our current scenario, we need to default the dashboard level to year to date (with option to adjust to any date via a date filter) and have other charts default to a different date range by default (e.g. MTD). When the user adjusts the filter at the dashboard level, all charts are updated to the new date range (e.g. 2019). Relative date filters do not appear to work in the scenario.
Looking for advice as to how a) set a date range filter that defaults to year to date (irrespective of how many years of data exists in the date set) at the dashboard level but can be changed outside of the YTD period when required using the date picker and b) how chart defaults can be overridden when a user changes the date range at the dashboard level (e.g. from a previous month default to last year if the latter is changed in the dashboard filter).
Is this possible? Thanks.
------------------------------
Dean
------------------------------
#CognosAnalyticswithWatson