COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: gosoccer on 16 May 2014 09:59:50 AM

Title: Filtering Query for Getting only the Last Month's Data in Report Author (Dim. H.
Post by: gosoccer on 16 May 2014 09:59:50 AM
Folks,
I was using the following for obtaining the last month's data in Relational Model without any problem.

Quote([DATE_TIME] between  _add_days(current_date,-30) and current_date)

We change to Dimensional Hierarchy and I'm trying to find the best code to include in the
Query Filtration in Report Author 10.2.1. I do have a Time Dimension with the Day as a level.

I also do have a DATE_TIME Level generated from the cube generation process I could include
in the Query and perform the necessary filtration instead of the Day level.

Please help if could.


Title: Re: Filtering Query for Getting only the Last Month's Data in Report Author (Dim. H.
Post by: navissar on 18 May 2014 12:49:24 AM
Assuming today's date is the last day of your time hierarchy, you could use:
lastPeriods (30,closingPeriod ([cube].[Time Dim].[Time Hierarchy].[Day Level]))
which will give you 30 days back from the last day in your time dimension.
If it isn't, you'll need to find the current date member. There are several methods to do that,I personally like to use macros. You can find a sample for using macros to figure out current date MUN here: http://www.linkedin.com/today/post/article/20140507205959-84415552-using-macros-to-create-dynamic-data-items?trk=prof-post (http://www.linkedin.com/today/post/article/20140507205959-84415552-using-macros-to-create-dynamic-data-items?trk=prof-post)