使用mondrian获取一个月中前2名成员的列表,其中"其他人"分组为一个成员。这之前已在MDX - TopCount plus 'Other' or 'The Rest' by group (over a set of members)进行了讨论,但在蒙德里安没有现有的功能。
我提出的查询(缺少topcount成员,但只是将UNION添加到GENERATE中的CROSSJOIN)是:
WITH SET ExceptSet AS
EXCEPT(
[campaign_subject].[subject].Members,
TOPCOUNT(
CROSSJOIN(
[date].[month].CurrentMember,
[campaign_subject].[subject].Members
),
2,
[Measures].[clicks]
)
)
MEMBER [campaign_subject].[(others)] AS
AGGREGATE(ExceptSet, [Measures].[clicks])
SELECT NON EMPTY {[Measures].[clicks]} ON COLUMNS,
NON EMPTY GENERATE({[date].[2014].[2].[5], [date].[2014].[2].[6]},
CROSSJOIN([date].[month].CurrentMember, {[campaign_subject].[(others)]})
)
ON ROWS FROM [Campaigns]
但是,此查询会返回月份的总计,并且不会排除topcount成员。单独查询ExceptSet似乎确实提供了正确的解决方案,但当然成员没有被分组为单个"(其他)"构件。
此处尝试制作AdvWrks版本:
WITH SET ExceptSet AS
EXCEPT(
[Employee].[Employee].[Employee].MEMBERS ,
TOPCOUNT(
CROSSJOIN(
[Date].[Calendar].CurrentMember,
[Employee].[Employee].[Employee].MEMBERS
),
2,
[Measures].[Reseller Sales Amount]
)
)
MEMBER [Employee].[Employee].[Others] AS
AGGREGATE(ExceptSet, [Measures].[Reseller Sales Amount])
SELECT NON EMPTY {[Measures].[Reseller Sales Amount]} ON 0,
NON EMPTY GENERATE({[Date].[Calendar Year].[CY 2006], [Date].[Calendar Year].[CY 2007]},
CROSSJOIN([Date].[Calendar].CurrentMember, {[Employee].[Employee].[Others]})
)
ON 1 FROM [Adventure Works]
答案 0 :(得分:0)
自定义集通常不支持上下文。
我的意思是在ExceptSet
里面你有这个:
...
`[Date].[Calendar].CurrentMember`
...
不幸的是,这可能是解决了所有成员而不是ON ROWS
。因此,在您引用的解决方案EXISTING
中,用于将上下文带入所有WITH
子句。
如何在不使用EXISTING
的情况下做一个简单的解决方案我不确定。