Cognos Analytics

Cognos Analytics

Connect, learn, and share with thousands of IBM Cognos Analytics users! 

 View Only
Expand all | Collapse all

How do I automatically filter a report to the previous month?

  • 1.  How do I automatically filter a report to the previous month?

    Posted Tue March 23, 2021 08:35 PM

    I've seen several answers in various places, but either they're outdated or I have no idea what I'm doing (likely both!).

    I found this example in one of the IBM support pages:

    [gosales_goretailers].[Orders].[Order date] between _first_of_month(_add_months(sysdate(),-1)) and _last_of_month(_add_months(sysdate(),-1))

    However, when substituting the query I get this error: RQP-DEF-0177 An error occurred while performing operation 'sqlPrepareWithOptions' status='-16'.

    I don't know what that means, but I would certainly appreciate any insight. If there are any free learning resources someone could point me to, that would be extremely helpful also - have a wonderful day!






    #CognosAnalytics
    #CognosAnalyticswithWatson
    #Support
    #SupportMigration


  • 2.  RE: How do I automatically filter a report to the previous month?
    Best Answer

    Posted Tue March 30, 2021 05:55 PM

    Hey! If you want to automatically filter to prior month, you could do it a couple of different ways. Your basic filter should look something like this:

    [*date you are filtering*] between _first_of_month(_add_months(current_date,-1)) and _last_of_month(_add_months(current_date,-1))

    I think sysdate() may be a vendor specific function, so it may not work with the specific database you connect to. current_date is a Cognos function to get the current system date, so it should work no matter what.

    Hope this helps!






    #CognosAnalytics
    #CognosAnalyticswithWatson
    #Support
    #SupportMigration


  • 3.  RE: How do I automatically filter a report to the previous month?
    Best Answer

    Posted Tue March 30, 2021 06:07 PM

    Thank you so much for your reply! Based on what I've read elsewhere, that really should work. When entering the expression I actually get the same error as before, but the part I'm not able to figure out is why other reports I can pull (already filtered by previous month) include identical text. These run without issue.

    Is there a special way to enter these expressions other than just double clicking the list header and entering it in the expression field? It's pretty obvious I'm brand new at this, and the sample reports are not included with my installation. Thanks again!






    #CognosAnalytics
    #CognosAnalyticswithWatson
    #Support
    #SupportMigration


  • 4.  RE: How do I automatically filter a report to the previous month?
    Best Answer

    Posted Tue March 30, 2021 06:10 PM

    Nevermind, that worked! Apparently I was entering it as a regular expression rather than a filter expression, if that makes sense. Thank you!






    #CognosAnalytics
    #CognosAnalyticswithWatson
    #Support
    #SupportMigration