WOPR
WOPR

Reputation: 5393

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,...')

Upvotes: 1

Views: 112

Answers (2)

Magnus Smith
Magnus Smith

Reputation: 5963

There are various shortcuts. If you just want all the 'children' of a certain member, use Descendants() or .children. Or get all the members at one level with .members. You can specify a range between two members, or use a filter to match some sort of critera.

What were you after? I'll try to give a more specific example...

Upvotes: 0

Meff
Meff

Reputation: 5999

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

Upvotes: 1

Related Questions