MDX-- 不同计数

发布于 2024-12-21 10:13:40 字数 1021 浏览 1 评论 0原文

我正在关注这篇文章:

http://msdn .microsoft.com/en-us/library/aa902637%28v=sql.80%29.aspx

我对不同计数的查询如下所示:

Count(CrossJoin({[Measures].[Submission Count]}, [Submission].[PK Submission].Members), ExcludeEmpty)

它始终返回 1超出了应有的范围(例如,它返回 27 而不是 26)。

在同一篇文章中,有这个查询(应该可以解决这个问题):

Count(CrossJoin( {[Sales]}, 
Descendants([Customers].CurrentMember, [Customer Names])),
 ExcludeEmpty)

但我无法让它工作。我已经尝试过这两个,但第二个总是返回 1 或 0,而第一个不起作用(错误:我必须显式定义级别):

Count(CrossJoin( {[Measures].[Submission Count]}, 
    Descendants([Submission].CurrentMember, [Submission].[PK Submission])),
     ExcludeEmpty)


Count(CrossJoin( {[Measures].[Submission Count]}, 
    Descendants([Submission].[PK Submission].CurrentMember, [Submission].[PK Submission])),
     ExcludeEmpty)

知道我做错了什么吗?

谢谢!

I was following this article:

http://msdn.microsoft.com/en-us/library/aa902637%28v=sql.80%29.aspx

and my query for distinct count looks like this:

Count(CrossJoin({[Measures].[Submission Count]}, [Submission].[PK Submission].Members), ExcludeEmpty)

it returns always 1 more than it should (for example it returns 27 instead of 26).

In the same article there is this query (which is suppose to solve this problem):

Count(CrossJoin( {[Sales]}, 
Descendants([Customers].CurrentMember, [Customer Names])),
 ExcludeEmpty)

But I can't get it to work. I've tried these two but second one always returns 1 or 0 while the first one doesn't work (error: I have to explicitly define a level):

Count(CrossJoin( {[Measures].[Submission Count]}, 
    Descendants([Submission].CurrentMember, [Submission].[PK Submission])),
     ExcludeEmpty)

Count(CrossJoin( {[Measures].[Submission Count]}, 
    Descendants([Submission].[PK Submission].CurrentMember, [Submission].[PK Submission])),
     ExcludeEmpty)

Any idea what am I doing wrong?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

与酒说心事 2024-12-28 10:13:40

第一个查询返回“比应有的多 1”的原因是因为 [Submission].[PK Submission].Members 元组集还包含 All 成员。

如果您引用 [PK Submission] 级别而不是 [PK Submission] 层次结构的所有成员,则它不包括 All 成员。

因此,以下返回您所期望的内容:

Count( CrossJoin( { [Measures].[Submission Count] }
                , { [Submission].[PK Submission].[PK Submission] })
     , ExcludeEmpty)

The reason the first query returns "1 more than it should" is because the [Submission].[PK Submission].Members tuple set also includes the All member.

If you refer to the [PK Submission] level instead of all the members of the [PK Submission] hierarchy, it doesn't include the All member.

So, the following returns what you're expecting:

Count( CrossJoin( { [Measures].[Submission Count] }
                , { [Submission].[PK Submission].[PK Submission] })
     , ExcludeEmpty)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文