Export (0) Print
Expand All
Expand Minimize

StrToMember (MDX)

Returns the member specified by a Multidimensional Expressions (MDX)–formatted string.


StrToMember(Member_Name [,CONSTRAINED] ) 

Member_Name

A valid string expression specifying, directly or indirectly, a member.

The StrToMember function returns the specified member. The StrToMember function is typically used with user-defined functions to return a member specification from an external function back to an MDX statement.

  • When the CONSTRAINED flag is used, the member name must be directly resolvable to a qualified or unqualified member name. This flag is used to reduce the risk of injection attacks via the specified string. If a string is provided that is not directly resolvable to a qualified or unqualified member name, the following error appears: "The restrictions imposed by the CONSTRAINED flag in the STRTOMEMBER function were violated."

  • When the CONSTRAINED flag is not used, the specified member can resolve either directly to a member name or can resolve to an MDX expression that resolves to a name.

Examples

The following example returns the Reseller Sales Amount measure for the Bayern member in the State-Province attribute hierarchy using the StrToMember function. The specified string provided the qualified member name.

SELECT StrToMember ('[Geography].[State-Province].[Bayern]')
ON 0
FROM [Adventure Works]

The following example returns the Reseller Sales Amount measure for the Bayern member using the StrToMember function. Since the member name string provided only an unqualified member name, the query returns the first instance of the specified member, which happens to be in the Customer Geography hierarchy in the Customer dimension, which does not intersect with the Reseller Sales. Best practices dictate specifying the qualified name to ensure expected results.

SELECT StrToMember ('[Bayern]').Parent
ON 0
FROM [Adventure Works]

The following example returns the Reseller Sales Amount measure for the Bayern member in the State-Province attribute hierarchy using the StrToMember function. The member name string provided resolves to a qualified member name.

SELECT StrToMember ('[Geography].[Geography].[Country].[Germany].FirstChild')
ON 0
FROM [Adventure Works]

The following example returns an error due to the CONSTRAINED flag. While the member name string provided contains a valid MDX member expression that resolves to a qualified member name, the CONSTRAINED flag requires qualified or unqualified member names in the member name string.

SELECT StrToMember ('[Geography].[Geography].[Country].[Germany].FirstChild', CONSTRAINED)
ON 0
FROM [Adventure Works]

Community Additions

ADD
Show:
© 2014 Microsoft