Dynamic Filtering based on Member properties

  • I've not done any serious MDX for about 18 months and this is starting to bug me.

    I want to create a YTD set, based on a Period setting.

    The Period dimension is All->Year->Qtr->Month, and has a member property on the Month that denotes the current period.

    In SSMS if I Run the Query

    Select

    FILTER

    (

    [Period].[Yr - Qtr - Mth].[Period].Members

    ,[Period].[Period].Properties("Is Current Period")

    ) ON ROWS, NULL ON COLUMNS

    FROM

    [CUBE]

    I get the correct result of 201405.

    However when place the FILTER in to the following into a CREATE MEMBER

    CREATE MEMBER CURRENTCUBE.[Measures].[YTD Measure]

    AGGREGATE

    (

    YTD

    (

    FILTER

    (

    [Period].[Yr - Qtr - Mth].[Period].Members

    ,[Period].[Period].Properties("Is Current Period")

    )

    )

    ,[Measures].[aMeasure]

    )

    I get a #Value, however If I switch the Filter in the YTD to

    STRTOMEMBER("[Period].[Yr - Qtr - Mth].[Period].["+FORMAT(NOW(),"yyyy")+FORMAT(NOW(),"MM")+"]")

    It works. The issue with this method is that the Current period doesn't 'switch' on the first of the month, and can be 2-3 days later once the source data has been signed off.

    _________________________________________________________________________
    SSC Guide to Posting and Best Practices

  • Perhaps a .Item(0) after the filter?

  • Nevyn (5/20/2014)


    Perhaps a .Item(0) after the filter?

    Thanks that works a treat though I had to use Item(0).Name, and wrap it all in a StrToMember

    The last issue is that it degrades the performance.

    I think the option is to create a dynamic/static set and then reference that.

    _________________________________________________________________________
    SSC Guide to Posting and Best Practices

  • Actually it may be .Item(0).Item(0).

    You are trying to get from the set that filter returns down to a member which YTD expects, even though the set has only one member. So you go set to tuple and tuple to member.

    Hopefully its just the strtomember stuff that is degrading performance.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply