简体   繁体   中英

MDX filtering by multiple dimension members

Problem

I need to create a report which will list a number of accounts that match certain criteria - simulationDate , statisticPeriod , region .

Right now my query looks like this:

WITH MEMBER [Measures].[Count] as 1
SELECT [Measures].[Count] ON COLUMNS,
NON EMPTY 
Crossjoin(
[Account].[Account Number].ALLMEMBERS,
{[simulationDate].[day].&[10010101]},
{[statisticPeriod].[period].&[201201]},
{[region].[code].&[SO]}
)
ON COLUMNS
FROM [myWH]

Is this cross-dimensional filtering okay?

This is slightly more modern using the * notation instead of the Crossjoin function:

WITH 
  MEMBER [Measures].[Count] AS 1 
SELECT 
  [Measures].[Count] ON COLUMNS
 ,NON EMPTY 
      [Account].[Account Number].ALLMEMBERS*
      {[simulationDate].[day].&[10010101]}*
      {[statisticPeriod].[period].&[201201]}*
      {[region].[code].&[SO]} ON COLUMNS
FROM [myWH];

I'm assuming that your custom measure [Measures].[Count] is just a place-holder?

This table will be very wide if you have that cross-join on COLUMNS but that might just be a typo:

WITH 
  MEMBER [Measures].[Count] AS 1 
SELECT 
  [Measures].[Count] ON COLUMNS, 
  NON EMPTY 
      [Account].[Account Number].ALLMEMBERS*
      {[simulationDate].[day].&[10010101]}*
      {[statisticPeriod].[period].&[201201]}*
      {[region].[code].&[SO]} ON ROWS
FROM [myWH];

You have added the keywords NON EMPTY in front of the rows cross-join. This is telling the processor to exclude any rows that are empty - empty for [Measures].[Count] ....but this measure is never empty it is always equal to 1. So the following without Non Empty should return exactly the same result:

WITH 
  MEMBER [Measures].[Count] AS 1 
SELECT 
  [Measures].[Count] ON COLUMNS, 
      [Account].[Account Number].ALLMEMBERS*
      {[simulationDate].[day].&[10010101]}*
      {[statisticPeriod].[period].&[201201]}*
      {[region].[code].&[SO]} ON ROWS
FROM [myWH];

So in terms of filtering you aren't doing any - what sort of filtering do you need? If you replace [Measures].[Count] with an actual measure from your cube and use the NON EMPTY then you should see a lot less rows:

SELECT 
  [Measures].[ReplaceWithActualMeasure] ON COLUMNS, 
  NON EMPTY
      [Account].[Account Number].ALLMEMBERS*
      {[simulationDate].[day].&[10010101]}*
      {[statisticPeriod].[period].&[201201]}*
      {[region].[code].&[SO]} ON ROWS
FROM [myWH];

In the end I ended up using the filters as my columns, and letting the NON EMPTY clause take care of the filtering:

SELECT 
 NON EMPTY 
    {[simulationDate].[day].&[10010101]} *
    {[statisticPeriod].[period].&[201201]} *
    {[region].[code].&[SO]}
 ON COLUMNS,
 NON EMPTY
    [Account].[Account Number].ALLMEMBERS 
 ON ROWS
FROM [myWH]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM