Better syntax for MDX

52 Views Asked by At

if there a better way to write the MDX

SELECT {         [Measures].[Label], 
        NonEmpty [Measures].[UniqueName],
        NonEmpty [Measures].[TargetName],
                 [Measures].[Place]
        } ON COLUMNS ,
NON EMPTY 
      [Geography].[Country].ALLMEMBERS ON ROWS FROM [Adventure Works]

I want to add non empty only for few measures and that depends on a dimension for example [Street Dimension].[street].[street name]="abcd". So can I but any condition to check for street name and add non empty only if the street name matches.

1

There are 1 best solutions below

0
On

More like this:

SELECT {[Measures].[Label], 
        [Measures].[UniqueName],
        [Measures].[TargetName],
        [Measures].[Place]} ON COLUMNS ,
      nonempty(
      nonempty(
        [Geography].[Country].ALLMEMBERS
        ,[Measures].[UniqueName])
        ,[Measures].[TargetName]
      ) 
ON ROWS 
FROM [Adventure Works]

To direct the NonEmpty functions at a specific member of the street hierarchy you can use a tuple as the second argument to each NonEmpty:

SELECT 
    {
      [Measures].[Label], 
      [Measures].[UniqueName],
      [Measures].[TargetName],
      [Measures].[Place]
    } ON COLUMNS,
      NonEmpty(
          NonEmpty(
            [Geography].[Country].ALLMEMBERS
            ,(
              [Measures].[UniqueName]
             ,[Street Dimension].[street].[street name].[abcd]
             )
          )
        ,(
          [Measures].[TargetName]
         ,[Street Dimension].[street].[street name].[abcd]
         )
      ) 
  ON ROWS 
FROM [Adventure Works];