1

我正在尝试创建一个 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]

一切正常,除了 [Other] 的百分比。谁能帮我解决这个最后的问题?

4

1 回答 1

0

成员 [Product].[Subcategory].CurrentMember.Parent 不是 [Other] 成员的父级。

试试这个解决方案:

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]
于 2012-02-08T16:26:59.470 回答