Selecting dimension's default member based on a member property

Suppose, I need to write an MDX statement that selects a certain month of my Time dimension based on a Month level member property, FLAG_LAST_MONTH, below are the two approaches:

SELECT {StrToMember(Date.CurrentMember.Properties("FLAG_LAST_MONTH"))} on rows,

{} on columns

from MyCube

or

Based on the property name: FLAG_LAST_MONTH, I assume that it has a value like "1" only for one month.  In that case, you could use Filter() to select the desired month member:

SELECT Filter([Date].[Month].Members,

[Date].CurrentMember.Properties("FLAG_LAST_MONTH") = "1") on rows

from MyCube

If you try to use the below query, you get an error, since Date.CurrentMember.Properties("FLAG_LAST_MONTH") - doesn't return a member,

SELECT {Date.CurrentMember.Properties("FLAG_LAST_MONTH")} on rows,
{Date.Month.Members} on columns
from MyCube

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=911884&SiteID=1

No comments:

My Articles

Design

Cube structure optimization for MDX query performance in Analysis Services 2005 SP2: Tips for Parent Child Hierarchies usage

Fact table design for “State Workflow Analysis”: Analysis Services Dimensional modeling

Handling inter-dimensional members dependency and reducing cube sparsity using reference dimensions in Analysis Services 2005 SP2 : Cube design tip

Identifying intra-dimensional members relationship and reducing cube sparsity in Analysis Services 2005 SP2 : Cube design tip

Leaves() : An example to understand it for both regular hierarchies as well as parent child hierarchies

Aggregation design: useful tips

Level based attribute hierarchy: MDX query performance woes in SQL Server 2005 SP2: Is it fixed in post SP2 hotfix?

Parent child hierarchy to level base hierarchy conversion: hiding placeholder dimension members in client application

Trouble / Troubleshooting

Aggregate(), Sum() functions using calculated members does not work in Analysis Services 2005 SP2 (9.00.3042.00 version) but works in Analysis Services 2000 SP4

Analysis Services 2005 migration tool: Custom member formula issues in migrated database

Cube Partitions: Fact table not listing in Business Intelligence Development Studio in partition wizard

Analysis Services 2005: Many-to-Many relationship does not support unary operators with parent-child dimension

MDX

NextAnalytics and MDX : Part 1 - Swap Cells with Row Labels

Selecting dimension's default member based on a member property

Sorting members on member codes / member properties

Time Dimension: How to set Default Member to Current Month

Setting dynamic default member in dimension X based on the current member of dimensions Y

ADOMD.NET

Code : utility code for converting cellset to a data table

Others

Google specialized search for Analysis Services and MDX web resources integrated in my blog

Art of reading MDX articles

MDX Expression Builder : Need for a tool making it easier for functional users to write MDX expressions, queries.

Blogroll