COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: sergiord2016 on 23 Oct 2018 10:04:53 AM

Title: previous member -12
Post by: sergiord2016 on 23 Oct 2018 10:04:53 AM
Hello!

Is there any way to get de previous member -12?

I have the member 201810 , (otober 2018) , and the previousmember is 201809.

I need to get 201710 so i want to get previousmember -12.
Title: Re: previous member -12
Post by: CognosPaul on 23 Oct 2018 02:49:22 PM
Try lag(member,12)

You could also look at parallelPeriod. lag(member,N) will always go back N members, regardless of which level of the hierarchy you're looking at. parallelPeriod will always go back to the period you want, so let's say you are showing the hierarchy in a set, year, month, day. Using tuple(lag(currentMember(dateHier),12),measure) would show the value of the year 12 years back, the month 12 months back, and the day 12 days back. parallelPeriod ensures that it's always going back one year. tuple(parallelPeriod(yearLevel,1,currentMember(dateHier)),measure) will always go back a single year.
Title: Re: previous member -12
Post by: erjorgea on 24 Oct 2018 11:44:00 AM
Hi ¡, I have similar problem, but in my case the current item is a "calculated item" as follow",

#'[BBDD_T].[TIEMPO MES DIA].[TIEMPO AÑO].[AÑO]->[all].['
+ (the snippet from before)
+']'#


How can I calculated the year -1?
Title: Re: previous member -12
Post by: CognosPaul on 24 Oct 2018 02:03:02 PM
In yours you are manually creating the member with a macro:

#'[BBDD_T].[TIEMPO MES DIA].[TIEMPO AÑO].[AÑO]->[all].['
+ timestampMask($current_timestamp,'yyyy')
+']'#


There are two ways you could go here. You could look for the prevMember from that:

prevMember(#'[BBDD_T].[TIEMPO MES DIA].[TIEMPO AÑO].[AÑO]->[all].['
+ timestampMask($current_timestamp,'yyyy')
+']'#)


Or you could calculate the previous year in the macro itself:

#'[BBDD_T].[TIEMPO MES DIA].[TIEMPO AÑO].[AÑO]->[all].['
+ timestampMask(_add_years($current_timestamp,-1),'yyyy')
+']'#

Title: Re: previous member -12
Post by: erjorgea on 25 Oct 2018 05:54:25 AM
thx for the support, now is working!! ;)
Title: Re: previous member -12
Post by: psrpsrpsr on 26 Oct 2018 08:59:15 AM
You could also try something like this: https://stackoverflow.com/questions/38959458/subtract-month-from-yearmonth

Of course with the database syntax and functions available to you.