Reputation: 73
I wrote a code to get this year and last year data using MDX in named sets. Now I want to get this month and last month data, I am using Monthkey, 'YYYYMM'
my code is
{strtomember(
"[Time].[Month Key].[" + cstr(year(dateadd('yyyy'+'mm',-1,now()))) +"]")
: strtomember("[Time].[Month Key].[" + cstr(year(now())) +"]"
)} ;
I need to change this to get this month and last month data with format of 'YYYYMM'.
Upvotes: 1
Views: 382
Reputation: 35557
I would maybe use strToSet
and don't forget your ampersands if you are using keys:
STRTOSET(
"[Time].[Month Key].&["
+ CSTR(YEAR(DATEADD("M",-1,now())))
+ CSTR(MONTH(DATEADD("M",-1,now())))
+ "] : "
+ "[Time].[Month Key].&["
+ CSTR(YEAR(now()))
+ CSTR(MONTH(now()))
+ "]"
);
Upvotes: 1