最高结果 +剩余结果,%

发布于 2025-01-03 06:16:59 字数 653 浏览 4 评论 0原文

我正在尝试创建一个 MDX 查询来显示前 10 个结果 + 属于前 10 个结果的所有其他结果的聚合。到目前为止,一切都很好。但我还想显示每个结果的百分比。这是我到目前为止所拥有的。您可以在Adventure Works中尝试:

WITH
SET [TCat] AS TopCount([Product].[Subcategory].[Subcategory],10,[Measures].[Sales Amount])
MEMBER [Product].[Subcategory].[Other] AS Aggregate([Product].[Subcategory].[Subcategory] - TCat)
MEMBER [Measures].[Percent] AS [Measures].[Sales Amount] / ([Measures].[Sales Amount],[Product].[Subcategory].CurrentMember.Parent),format_string='0.00%'

SELECT { [Measures].[Sales Amount], [Measures].[Percent] } ON COLUMNS,
TCat + [Other] ON ROWS
FROM [Adventure Works]

一切正常,除了[其他]的%。 有人能帮我解决这个最后的问题吗?

I'm trying to create a MDX query to show the top 10 results + an aggregation of all other results that are part of the 10 first. So far so good. But I also want to show the percentage of each result. This is what I have so far. You can try in Adventure Works:

WITH
SET [TCat] AS TopCount([Product].[Subcategory].[Subcategory],10,[Measures].[Sales Amount])
MEMBER [Product].[Subcategory].[Other] AS Aggregate([Product].[Subcategory].[Subcategory] - TCat)
MEMBER [Measures].[Percent] AS [Measures].[Sales Amount] / ([Measures].[Sales Amount],[Product].[Subcategory].CurrentMember.Parent),format_string='0.00%'

SELECT { [Measures].[Sales Amount], [Measures].[Percent] } ON COLUMNS,
TCat + [Other] ON ROWS
FROM [Adventure Works]

Everything works fine, except for the % of [Other].
Can anybody help me to fix this final issue?

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

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

发布评论

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

评论(1

旧话新听 2025-01-10 06:16:59

成员 [产品].[子类别].CurrentMember.Parent 不是 [其他] 成员的父级。

尝试这个解决方案:

WITH
MEMBER [Product].[Subcategory].[Parent] AS Aggregate([Product].[Subcategory].[Subcategory])
SET [TCat] AS TopCount([Product].[Subcategory].[Subcategory],10,[Measures].[Sales Amount])
MEMBER [Product].[Subcategory].[Other] AS Aggregate([Product].[Subcategory].[Subcategory] - TCat)
MEMBER [Measures].[Percent] AS [Measures].[Sales Amount] / ([Measures].[Sales Amount], [Product].[Subcategory].[Parent]),format_string='0.00%'

SELECT { [Measures].[Sales Amount], [Measures].[Percent] } ON COLUMNS,
TCat + [Other] ON ROWS
FROM [Adventure Works]

The Member [Product].[Subcategory].CurrentMember.Parent isn't Parent from [Other] Member.

Try this solution:

WITH
MEMBER [Product].[Subcategory].[Parent] AS Aggregate([Product].[Subcategory].[Subcategory])
SET [TCat] AS TopCount([Product].[Subcategory].[Subcategory],10,[Measures].[Sales Amount])
MEMBER [Product].[Subcategory].[Other] AS Aggregate([Product].[Subcategory].[Subcategory] - TCat)
MEMBER [Measures].[Percent] AS [Measures].[Sales Amount] / ([Measures].[Sales Amount], [Product].[Subcategory].[Parent]),format_string='0.00%'

SELECT { [Measures].[Sales Amount], [Measures].[Percent] } ON COLUMNS,
TCat + [Other] ON ROWS
FROM [Adventure Works]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文