简体   繁体   English

MDX忽略Excel过滤器

[英]MDX ignoring Excel filter

I'm just starting to get my head around MDX and I'm having trouble with a calculated member. 我才刚开始了解MDX,但遇到一名有经验的成员时遇到了麻烦。 I'm using the following MDX: 我正在使用以下MDX:

IIF( ISEMPTY((Axis(1).Item(0).Item(0).Dimension.CurrentMember, [Measures].[Qty])) ,NULL ,([Product].[Product Code].CurrentMember.Parent, [Measures].[Qty]) IIF(ISEMPTY((Axis(1).Item(0).Item(0).Dimension.CurrentMember,[Measures]。[Qty])),NULL,([[Product]。[Product Code] .CurrentMember.Parent, [度量]。[数量])

)

What I'm trying to do is get a total quantity of the group of products displayed in a cube. 我想做的是获取显示在多维数据集中的一组产品的总数。 I then use that total to divide by each product's quantity to get a "percent of total" measure. 然后,我使用该总数除以每种产品的数量,得出“总数的百分比”度量。 The above MDX does correctly return the total quantity of products displayed in any dimension. 上面的MDX可以正确返回任何维度上显示的产品总数。 However, when a user in Excel changes the filter on which products are displayed, the MDX above still displays the total quantity for the whole group, ignoring which products the user has checked. 但是,当用户使用Excel更改显示产品的过滤器时,上面的MDX仍会显示整个组的总数,而忽略用户检查了哪些产品。 I assume I'm lacking some basic understanding of MDX, how do I get the calculated measure to account for the product codes the user has selected in Excel? 我假设我对MDX缺乏基本的了解,如何获得计算得出的度量值来说明用户在Excel中选择的产品代码?

With Visual Studio SQL Server Data Tools (if you are using that tool), you can browse to your cube, select the Calculations tab, and under Calculations Tools > Templates there is a template "Percentage of Total". 使用Visual Studio SQL Server数据工具(如果正在使用该工具),可以浏览到多维数据集,选择“计算”选项卡,然后在“计算工具”>“模板”下有一个模板“总计百分比”。 The MDX this tool provides is flexible so that the percentage adjusts with the attributes of the hierarchy you've pulled into the pivot. 该工具提供的MDX十分灵活,因此百分比可以根据您拉入数据透视表的层次结构的属性进行调整。

Case
// Test to avoid division by zero.
When IsEmpty
 ( 
    [Measures].[<<Target Measure>>] 
 ) 
Then Null

Else ( [<<Target Dimension>>].[<<Target Hierarchy>>].CurrentMember,
   [Measures].[<<Target Measure>>] ) 
 /
 ( 
   // The Root function returns the (All) value for the target dimension.
   Root     
   ( 
      [<<Target Dimension>>] 
    ), 
    [Measures].[<<Target Measure>>] 
 )
End

I found this option to work when developing to achieve what you've mentioned. 我发现在实现您所提到的目标时,此选项有效。

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

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