如果成员标识符名称不同,则多维数据集的Mdx查询将为“ With Member”返回不同的结果

时间:2019-05-15 06:37:29

标签: ssas mdx cube

我正在触发mdxquery以使用“ With Member”为不同的单元格获取不同的元组集组合。我的要求是在单个mdx查询中查询具有多个维度的元组。 根据我的理解,成员标识符只是一个别名,它不会影响查询结果。但是,如果我使用单独的成员标识符,则它为同一查询返回不同的结果集。切片器的过滤器也相同。 我的要求是,我有一组元组,每个元组具有不同的成员维度/属性组合,并且我只想触发一个查询以获取这些元组中每组的数据。因此,我使用“带有成员”选项,该选项允许具有不同维数的命名成员集。

查询1,查询2,查询3几乎相同,只是所使用的成员名称对于所有成员均不同。任何帮助或建议都将受到高度赞赏。

Query 1: 
With 
MEMBER [Account].[9] AS '([Account].&[500],[Department].&[102])' 
MEMBER [Account].[1] AS '([Account_Text].[Account_Text_Level].&[-1],[Account].&[161])' 
MEMBER [Account].[6] AS '([Account].&[500],[Account_Group].&[214])' 
MEMBER [Account].[10] AS '([Account].&[1])' 
MEMBER [Account].[13] AS '([Account].&[2881],[Company].&[173])' 
MEMBER [Account].[4] AS '([Company].&[1],[Company_Text].&[-1],[Account].&[500],[Account_Group].&[215],[Account_Text].[Account_Text_Level].&[-1],[Department].&[103])' 
Select 
{[Account].[9],[Account].[1],[Account].[6],[Account].[10],[Account].[13],[Account].[4]} 
Dimension Properties [Parent_Unique_Name] On Columns From [Adventure Works] 
Where ([BusinessCenter].&[1],[CalculatedDim].&[1],[CostCenter].&[1],[Department].&[1],[Geography].&[1],[ICSegment].&[1],
[ProductLine].&[1],[Reporting].[Level 1].&[14],[Company].&[1],[Scenario].&[1],[Time].&[2014])


Query 2:
With 
MEMBER [Test9] AS '([Account].&[500],[Department].&[102])' 
MEMBER [Test1] AS '([Account_Text].[Account_Text_Level].&[-1],[Account].&[161])' 
MEMBER [Test2] AS '([Account].&[500],[Account_Group].&[214])' 
MEMBER [Test10] AS '([Account].&[1])' 
MEMBER [Test13] AS '([Account].&[2881],[Company].&[173])' 
MEMBER [Test4] AS '([Company].&[1],[Company_Text].&[-1],[Account].&[500],[Account_Group].&[215],[Account_Text].[Account_Text_Level].&[-1],[Department].&[103])' 
Select 
{[Test9],[Test1],[Test2],[Test10],[Test13],[Test4]} 
Dimension Properties [Parent_Unique_Name] 
On Columns From  [Adventure Works]  
Where ([BusinessCenter].&[1],[CalculatedDim].&[1],[CostCenter].&[1],[Department].&[1],[Geography].&[1],
[ICSegment].&[1],
[ProductLine].&[1],[Reporting].[Level 1].&[14],[Company].&[1],[Scenario].&[1],[Time].&[2014]
)

Query 3:

With 
MEMBER [Company].[9] AS '([Account].&[500],[Department].&[102])' 
MEMBER [Company].[1] AS '([Account_Text].[Account_Text_Level].&[-1],[Account].&[161])' 
MEMBER [Company].[6] AS '([Account].&[500],[Account_Group].&[214])' 
MEMBER [Company].[10] AS '([Account].&[1])' 
MEMBER [Company].[13] AS '([Account].&[2881],[Company].&[173])' 
MEMBER [Company].[4] AS '([Company].&[1],[Company_Text].&[-1],[Account].&[500],[Account_Group].&[215],[Account_Text].[Account_Text_Level].&[-1],[Department].&[103])' 
Select 
{[Company].[9],[Company].[1], [Company].[6],[Company].[10],[Company].[13],[Company].[4]} 
Dimension Properties [Parent_Unique_Name] On Columns From  [Adventure Works]  
Where ([BusinessCenter].&[1],[CalculatedDim].&[1],[CostCenter].&[1],[Department].&[1],[Geography].&[1],[ICSegment].&[1],
[ProductLine].&[1],[Reporting].[Level 1].&[14],[Scenario].&[1],[Time].&[2014],[Account].&[1])

1 个答案:

答案 0 :(得分:1)

我的回答基于您的评论。

  

我有一组元组,每个元组都有不同的成员,我想要   仅触发一个查询来获取每个元组集的数据。所以我   正在使用“具有成员”选项,该选项允许具有已命名的成员集   具有不同的尺寸–苏迪

您遇到的问题涉及维度和层次结构的概念。层次结构表示集合中的所有元组都应包含相同的维层次结构,而Dimensionality则表示它们必须具有相同的顺序。因此,如果元组缺少成员,则可以在查询中使用其默认成员来满足该属性。这将不会影响结果,因为查询处理器将对元组中遗漏的每个维度进行操作。您的查询将类似于。

Select 
{
([Account].&[500], [Department].&[102],                       [Account_Text].[Account_Text_Level].defaultmember, [Account_Group].[YourHierarchy].defaultmember, [Company].[YourHierarchy].defaultmember,[Company_Text].[YourHierarchy].defaultmember),
([Account].&[161], [Department].[Youhierarchy].defaultmember, [Account_Text].[Account_Text_Level].&[-1],         [Account_Group].[YourHierarchy].defaultmember, [Company].[YourHierarchy].defaultmember,[Company_Text].[YourHierarchy].defaultmember),
([Account].&[500], [Department].[Youhierarchy].defaultmember, [Account_Text].[Account_Text_Level].defaultmember, [Account_Group].&[214]                       , [Company].[YourHierarchy].defaultmember,[Company_Text].[YourHierarchy].defaultmember),
([Account].&[1],   [Department].[Youhierarchy].defaultmember, [Account_Text].[Account_Text_Level].defaultmember, [Account_Group].[YourHierarchy].defaultmember, [Company].[YourHierarchy].defaultmember,[Company_Text].[YourHierarchy].defaultmember),
([Account].&[2881],[Department].[Youhierarchy].defaultmember, [Account_Text].[Account_Text_Level].defaultmember, [Account_Group].[YourHierarchy].defaultmember, [Company].&[173]),
([Account].&[500], [Department].&[103],                       [Account_Text].[Account_Text_Level].&[-1],         [Account_Group].&[215]                       ,[Company].&[1]                          ,[Company_Text].&[-1])
} 
Dimension Properties [Parent_Unique_Name] On Columns 
From [Adventure Works] 
Where 
([BusinessCenter].&[1],[CalculatedDim].&[1],
[CostCenter].&[1],[Department].&[1],
[Geography].&[1],[ICSegment].&[1],
[ProductLine].&[1],[Reporting].[Level 1].&[14],
[Company].&[1],[Scenario].&[1],[Time].&[2014])

编辑:根据下面的评论

看看

select 
[Measures].[Internet Sales Amount]
on columns,
([Date].[Calendar Year].&[2012],[Product].[Category].&[1])
on 
rows 
from [Adventure Works]

结果 enter image description here

第二元组

select 
[Measures].[Internet Sales Amount]
on columns,
([Date].[Calendar Year].&[2012],[Customer].[Country].&[United States])
on 
rows 
from [Adventure Works]

结果: enter image description here

第三元组

select 
[Measures].[Internet Sales Amount]
on columns,
{
([Customer].[Gender].&[F],[Product].[Category].&[3])
}
on 
rows 
from [Adventure Works]

结果 enter image description here

现在让它们结合起来

select 
[Measures].[Internet Sales Amount]
on columns,
{
([Date].[Calendar Year].&[2012],[Product].[Category].&[1],[Customer].[Country].defaultmember,[Customer].[Gender].defaultmember),
([Date].[Calendar Year].&[2012],[Product].[Category].defaultmember,[Customer].[Country].&[United States],[Customer].[Gender].defaultmember),
([Date].[Calendar Year].defaultmember,[Product].[Category].&[3],[Customer].[Country].defaultmember,[Customer].[Gender].&[F])
}
on 
rows 
from [Adventure Works]

结果 enter image description here