Monday, March 12, 2012

How to use MDX script in RS dimension filter (dataview)

Hi, I need to create filter which retrieves data for current moment. [time].[date].lastchild is not an option because the calender in database is generated till following year (2008).

I guess script goes like..

[time].[date].currentmember

but it does not work.

I'm green with these MDX scripts.. I'd be very pleased if some one of you gurus could help me.

Best Regards,
Eeva

You can use StrToMember() for this, e.g.:

StrToMember ("[Date].[Calendar Date].[2003].[H" +

CStr(IIf(Month(Now()) <= 6, 1, 2)) + " CY 2003].[Q" +

CStr(DatePart("q", Now())) + " CY 2003].[" + Format(Now(), "MMMM") + "].[" +

Format(Now(), "MMMM") + " " + CStr(Day(Now())) + "]")

assuming Year-Half Year - Quarter - Month - Day user-defined hierarchy. If you use a special format for the Date dimension key, e.g. YYYYMMDD and you should, then you can simplify the above syntax and use the Day attribute hierarchy directly, e.g. [Date].[Day].[Day].&[20070323]

No comments:

Post a Comment