如何确定维度是否相关?
我正在开发一个生成 MDX 的查询生成器应用程序,并尝试使用以下方法从多维数据集中获取客户计数,效果很好:
WITH MEMBER MEASURES.X AS (
{ [Customer].[Gender].[Female]},
[Customer].[Customer].Children
).Count
SELECT Measures.X ON 0 FROM [Adventure Works]
但是,如果用户拖动与客户无关的维度,例如:
WITH MEMBER MEASURES.X AS (
{ [Customer].[Gender].[Female]},
{ [Employee].[Status].[Active], [Employee].[Status].[Inactive]},
[Customer].[Customer].Children
).Count
SELECT Measures.X ON 0 FROM [Adventure Works]
计数结果显然变得不正确。
有没有办法确定维度是否与客户相关,以便我可以将其从生成的 MDX 查询中排除?
I am developing a query builder application that generates MDX and trying to get customer counts from a cube using the following, which works just fine:
WITH MEMBER MEASURES.X AS (
{ [Customer].[Gender].[Female]},
[Customer].[Customer].Children
).Count
SELECT Measures.X ON 0 FROM [Adventure Works]
However, if the user drags in a dimension that is not related to the customer like:
WITH MEMBER MEASURES.X AS (
{ [Customer].[Gender].[Female]},
{ [Employee].[Status].[Active], [Employee].[Status].[Inactive]},
[Customer].[Customer].Children
).Count
SELECT Measures.X ON 0 FROM [Adventure Works]
the count result obviously becomes incorrect.
Is there a way to determine whether a dimension is related to the customer so that I can exclude it from the generated MDX query?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
可以通过 AMO。
Cube
类包含您需要的所有多维数据集元数据。This information can be retrieved from the cube through AMO. The
Cube
class contains all the cube metadata you'll need.使用 Exists( Set_Expression1 , Set_Expression2 [, MeasureGroupName] ) 解决了该问题 功能。无需手动确定哪些维度相关。 Exists 函数过滤掉不相关的元组,只留下
{ [Customer].[Customer].Children, [Customer].[Gender].[Female]}
设置为重新计数。这是 MDX:
Solved the problem by using the Exists( Set_Expression1 , Set_Expression2 [, MeasureGroupName] ) function. No need to manually determine which dimensions are related. The Exists function filters out the unrelated tuples, leaving only the
{ [Customer].[Customer].Children, [Customer].[Gender].[Female]}
set to do the count over.Here is the MDX: