COGNOiSe.com - The IBM Cognos Community

IBM Cognos Analytics Platform => Cognos Analytics => Reporting => Topic started by: oscarca on 08 Apr 2020 06:25:01 AM

Title: Create a member that returns previous year and january month
Post by: oscarca on 08 Apr 2020 06:25:01 AM
I would like to create a member that returns current year and January dynamically.

I have created the following which works great:
Current Period (yyyyMM)

#'[GeneralLedger_CostFollowUp].[Time].[Year-Month-Day].[Period]->:[M17].[[Time]].[Year-Month-Day]].[Period]].&['+
timestampMask($current_timestamp,'yyyy')
+
timestampMask($current_timestamp,'mm')
+']]]'#


Now I would like to create Previous year and January month for example 201901:

#'[GeneralLedger_CostFollowUp].[Time].[Year-Month-Day].[Period]->:[M17].[[Time]].[Year-Month-Day]].[Period]].&['+
timestampMask(_add_years($current_timestamp,-1),'yyyy')
+
timestampMask(_add_days($current_timestamp,(_day_of_year($current_timestamp) * -1) + 1),'mm')
+']]]'#


But I am stuck with the following error:
XQE-CON-0007 XQE error encountered: MacroException - a parsing error was encountered in the macro.
Encountered: "(" at line 4, column 44.
Was expecting one of:
    <INTEGER_LITERAL> ...
    <STRING_LITERAL> ...
    "$" ...
    "%" ...
    "@" ...
    "[" ...
    "{" ...
    <IDENTIFIER> ...
Text to expand:
#'[GeneralLedger_CostFollowUp].[Time].[Year-Month-Day].[Period]->:[M17].[[Time]].[Year-Month-Day]].[Period]].&['+
timestampMask(_add_years($current_timestamp,-1),'yyyy')
+
timestampMask(_add_days($current_timestamp,(_day_of_year($current_timestamp) * -1) + 1),'mm')
+']]]'#

Best regards,
Oscar

Title: Re: Create a member that returns previous year and january month
Post by: oscarca on 14 Apr 2020 01:18:35 AM
Solved it with a less pretty solution:

#'[GeneralLedger_CostFollowUp].[Time].[Year-Month-Day].[Period]->:[M17].[[Time]].[Year-Month-Day]].[Period]].&['+
timestampMask(_add_years($current_timestamp,-1),'yyyy')
+
01
+']]]'#