使用MDX查询检索数据的正确方法是哪一种?

使用MDX查询检索数据的正确方法是哪一种?,mdx,olap,Mdx,Olap,例如,我对[Geography].[All Geographies].[Canada].[Alberta]和[Product].[Product Categories].[All Products].[Accessories]交叉点处的[Measures].[Internet Sales Amount]感兴趣,我使用下面的MDX查询获得结果: select {[Measures].[Internet Sales Amount]} on axis(0), {[Geography].[G

例如,我对[Geography].[All Geographies].[Canada].[Alberta]和[Product].[Product Categories].[All Products].[Accessories]交叉点处的[Measures].[Internet Sales Amount]感兴趣,我使用下面的MDX查询获得结果:

select 
  {[Measures].[Internet Sales Amount]} on axis(0), 
  {[Geography].[Geography].[All Geographies].[Canada].[Alberta]} on axis(1),
  {[Product].[Product Categories].[All Products].[Accessories]} on axis(2)
from [Adventure Works]
结果是:700760

另一方面,我也使用下面的MDX查询:

select 
  {[Measures].[Internet Sales Amount]} on axis(0), 
  DESCENDANTS({[Geography].Geography].[All Geographies].[Canada].[Alberta]},2,LEAVES) on axis(1),
  DESCENDANTS({[Product].[Product Categories].[All Products].[Accessories]},2,LEAVES) on axis(2) 
  from [Adventure Works]
检索叶级节点值并尝试对其求和。数据是

celMeasure":[[7425,69],[7425,68],[27106,67],[27106,66],[9480,65],[9480,64],[7307,63],[7307,62],[15444,61],[15444,60],[23141,59],[23141,58],[34818,57],[34818,56],[22436,55],[22436,54],[21541,53],[21541,52],[27971,51],[27971,50],[48860,49],[48860,48],[40308,33],[40308,32],[78028,31],[78028,30],[74354,25],[74354,24],[72954,19],[72954,18],[46620,13],[46620,12],[7219,11],[7219,10],[21178,9],[21178,8],[15391,7],[15391,6],[20230,5],[20230,4],[39591,3],[39591,2],[39360,1],[39360,0]]
汇总结果为:1401524


为什么使用这两种方法的结果不同?哪一个是正确的?

您得到不同结果的原因是“地理”维度与Adventure Works中的“互联网销售”度量组无关!因此,轴(1)的每个成员显示相同的销售值。在第一个查询中,该轴有一个成员:“Alberta”,在第二个查询中,它有两个成员:“T2P2G8”和“T5”。因此,每个产品的每个值在第二个报告中重复两次,因此,如果将它们相加,将得到第一个查询的两倍数量


对于“哪一个是正确的?”:这取决于你想看到什么。但很可能,它们都不是你想要使用的。在查询中使用
[Customer].[Customer Geography]
层次结构,而不是
[Geography].[Geography]
层次结构,因为它与Internet Sales Measures group相关。

哇,非常感谢!这就是我需要的!非常感谢。