MDX - With Member

  • I saw mdx codes example using the "With Member" like

    1. With Member Test1 as ....

    2. With Member Measures.Test1 as ...

    3. With Member DimensionName.HierarchyName.Test1 as ....

    As far as I see #1 and #2 work the same, while #3 is different. But I am not clear what the difference is. More importantly, I need guidelines on which option I should use.

    Thanks.

  • seaport (3/24/2015)


    I saw mdx codes example using the "With Member" like

    1. With Member Test1 as ....

    2. With Member Measures.Test1 as ...

    3. With Member DimensionName.HierarchyName.Test1 as ....

    As far as I see #1 and #2 work the same, while #3 is different. But I am not clear what the difference is. More importantly, I need guidelines on which option I should use.

    Thanks.

    This MSDN article explains it best: https://msdn.microsoft.com/en-us/library/ms146017.aspx

  • Martin,

    Thanks for the link. It is good start.

    As my tests showed, which hierarchy to use for a query-scoped calculated member is subjective. The query works regardless which hierarchy I pick.

    The only situation it does not work is where I create a member based solely on a dimension attribute, like creating a rollup, then the calculated member must be in the "Measures" dimension. Putting the member in any other dimension will result in error

    "Two sets specified in the function have different dimensionality".

  • It really depends on what you're trying to do. The first 2 you have on your list are really the same...by default, if you create a calculated member it will go to the "Measures dimension".

    Where you could use the "...[Dimension]..." syntax is when you want to create a calculated set and include it within the original dimension. For instance, let's say you want to create a set which contains the first day of every week and still show it with the other date attributes on that axis.

    In that scenario, you would create a calculated set:

    with set [Date].[Calendar Date].[Sundays]

    as

    ...

    You could then use it in your MDX query as follows:

    select {...} on 0

    , {

    [Date].[Calendar Date].[Calendar Year]

    , [Date].[Calendar Date].[Sundays]

    } on 1

    from ...

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

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