如何确定维度是否相关?

发布于 2024-11-15 09:22:36 字数 592 浏览 10 评论 0原文

我正在开发一个生成 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

倥絔 2024-11-22 09:22:36

可以通过 AMO。 Cube 类包含您需要的所有多维数据集元数据。

This information can be retrieved from the cube through AMO. The Cube class contains all the cube metadata you'll need.

莳間冲淡了誓言ζ 2024-11-22 09:22:36

使用 Exists( Set_Expression1 , Set_Expression2 [, MeasureGroupName] ) 解决了该问题 功能。无需手动确定哪些维度相关。 Exists 函数过滤掉不相关的元组,只留下
{ [Customer].[Customer].Children, [Customer].[Gender].[Female]} 设置为重新计数。

这是 MDX:

WITH MEMBER MEASURES.X AS Exists(
    [Customer].[Customer].Children,
    {[Customer].[Gender].[Female]}
    *
    {[Employee].[Status].[Active], [Employee].[Status].[Inactive]}
).Count
SELECT Measures.X ON 0 FROM [Adventure Works]

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:

WITH MEMBER MEASURES.X AS Exists(
    [Customer].[Customer].Children,
    {[Customer].[Gender].[Female]}
    *
    {[Employee].[Status].[Active], [Employee].[Status].[Inactive]}
).Count
SELECT Measures.X ON 0 FROM [Adventure Works]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文