我正在尝试创建一个MDX查询来显示前10个结果+所有其他结果的聚合,这些结果是10个结果的一部分。到现在为止还挺好。但我也希望显示每个结果的百分比。这就是我到目前为止所拥有的。你可以尝试冒险作品:
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]的%之外,一切正常。 有人可以帮我解决这个最后的问题吗?
答案 0 :(得分:0)
会员[产品]。[子类别] .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]