Export (0) Print
Expand All
Avg
IIf
Lag
Max
Min
Mtd
Qtd
Sum
Var
Wtd
Ytd
Expand Minimize

StrToSet (MDX)

Updated: 17 July 2006

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


StrToSet(Set_Specification [,CONSTRAINED] ) 

Set_Specification

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

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

  • When the CONSTRAINED flag is used, the set specification must contain qualified or unqualified member names or a set of tuples containing qualified or unqualified member names enclosed by braces {}. 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 qualified or unqualified member names, the following error appears: "The restrictions imposed by the CONSTRAINED flag in the STRTOSET function were violated."
  • When the CONSTRAINED flag is not used, the specified set specification can resolve to a valid Multidimensional Expressions (MDX) expression that returns a set.

Examples

The following example returns the set of members of the State-Province attribute hierarchy using the StrToSet function. The set specification provided a valid MDX set expression.

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

The following example returns an error due to the CONSTRAINED flag. While the set specification provided a valid MDX set expression, the CONSTRAINED flag requires qualified or unqualified member names in the set specification.

SELECT StrToSet ('[Geography].[State-Province].Members', CONSTRAINED)
ON 0
FROM [Adventure Works]

The following example returns the Reseller Sales Amount measure for the countries of Germany and Canada. The set specification provided in the specified string contains qualified member names, as required by the CONSTRAINED flag.

SELECT StrToSet ('{[Geography].[Geography].[Country].[Germany],[Geography].[Geography].[Country].[Canada]}', CONSTRAINED)
ON 0
FROM [Adventure Works]

Release History

17 July 2006

Changed content:
  • Updated syntax and arguments to improve clarity.
  • Added updated examples.

Community Additions

ADD
Show:
© 2014 Microsoft