简体   繁体   English

通过多维成员过滤MDX

[英]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 . 我需要创建一个报告,该报告将列出一些符合某些条件的帐户simulationDatestatisticPeriodregion

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: 使用*表示Crossjoin代替Crossjoin函数会稍微更现代:

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? 我假设您的自定义指标[Measures].[Count]只是一个占位符?

This table will be very wide if you have that cross-join on COLUMNS but that might just be a typo: 如果您在COLUMNS上进行交叉COLUMNS ,则该表将非常宽,但这可能只是一个错字:

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. 您已在交叉连接的行前面添加了关键字NON EMPTY 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: 这是告诉处理器以排除任何空行-为空[Measures].[Count] ....但这一措施是从来没有空它总是等于1所以没有跟随Non Empty应返回一模一样结果:

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: 如果用多维数据集中的实际度量替换[Measures].[Count]并使用NON EMPTY,那么应该看到的行要少得多:

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: 最后,我最终将过滤器用作列,并让NON EMPTY子句负责过滤:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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