我正在尝试编写一个mdx查询,该查询将计算3个不同列中每个产品的收入百分比,具体取决于百分比" base" - 集团(产品所在)收入,子集收入和总收入。到目前为止这是我的代码
with
member [Measures].[Percent] as
([Measures].[Income]) /
([Products].[product].currentmember.parent,
[Measures].[Income])
,format_string = "percent"
select
{
[Measures].[Percent]
}
on columns,
{
[Products].[Product].[Product]
}
on rows
from [CUBE]
它根据总收入计算百分比,但我不知道如何更改代码以填写我之前提到的标准。我尝试以多种不同方式重新排列代码,(尝试计算sobgroup百分比示例)
with
member [Measures].[Percent] as
([Measures].[Income], [Products].[Subgroup]) /
([Products].[product].currentmember.parent,
[Measures].[Income])
,format_string = "percent"
等但我只得到相同的结果或错误。我对mdx仍然很新,所以任何帮助或提示都会非常感激。
答案 0 :(得分:0)
我仍然不确定要求,但如果您愿意,可以添加额外的父母:
WITH
MEMBER [Measures].[Percent_ofSubCategory] as
DIVIDE(
[Measures].[Income]
,([Measures].[Income], [Towary].[Hierarchy].currentmember.parent)
)
,format_string = "percent"
MEMBER [Measures].[Percent_ofCategory] as
DIVIDE(
[Measures].[Income]
,([Measures].[Income], [Towary].[Hierarchy].currentmember.parent.parent)
)
,format_string = "percent"
MEMBER [Measures].[Percent_ofAll] as
DIVIDE(
[Measures].[Income]
,([Measures].[Income], [Towary].[Hierarchy].[All])
)
,format_string = "percent"
SELECT
{
[Measures].[Percent_ofSubCategory]
,[Measures].[Percent_ofCategory]
,[Measures].[Percent_ofAll]
}
on 0,
[Towary].[Hierarchy].[Towar].[Towar].members
on 1
from [CUBE];