Search code examples
mdxssas

A shorter way of specifying a set in MDX


Is there a briefer way of specifying a set in MDX?

I know I can do something like :

{[Debtor].[TRADING DEBTOR CODE].&[AU-000013],[Debtor].[TRADING DEBTOR CODE].&[AU-000020]}

but once you get over a few members, it becomes incredibly verbose.

I'm looking for something like

MagicFunctionToMakeASet([Debtor].[TRADING DEBTOR CODE],'AU-000013,AU-000015,AU-000013,AU-000015,...')

Solution

  • Are they in sequence at all? If so, could you do

    {
          [Debtor].[TRADING DEBTOR CODE].&[AU-000013] : 
          [Debtor].[TRADING DEBTOR CODE].&[AU-000020]
    }
    

    To give you a set of codes 13 though to 20 inclusive?

    Failing that, take a look at InStr and see if it can help, it looks like it might - Or you could create some subsets using it and then combine into your final set?

    http://msdn.microsoft.com/en-us/library/ms145487.aspx

    From the above MSDN:

    WITH SET [ChardonnayChablis] AS
       'Filter([Product].Members, (InStr(1, [Product].CurrentMember.Name, "chardonnay") <> 0) OR (InStr(1, [Product].CurrentMember.Name, "chablis") <> 0))'
    
    SELECT
       [ChardonnayChablis] ON COLUMNS,
       {Measures.[Unit Sales]} ON ROWS
    FROM Sales