下面是针对AdvWrks
类似于您的情况为例:
WITH
SET [AllCountries] AS [Country].[Country].MEMBERS
SET [AllStates] AS [State-Province].[State-Province].MEMBERS
SET [Top2States] AS
Generate
(
[AllCountries]
,TopCount
(
(EXISTING
[AllStates])
,3
,[Measures].[Internet Order Count]
)
)
MEMBER [State-Province].[All].[RestOfCountry] AS
Aggregate({(EXISTING {[AllStates]} - [Top2States])})
SELECT
{[Measures].[Internet Order Count]} ON COLUMNS
,{
[AllCountries]
*
{
[Top2States]
,[State-Province].[All].[RestOfCountry]
,[State-Province].[All]
}
} ON ROWS
FROM [Adventure Works];
它提供了以下结果:
所以,如果我试图适应上面的一个d简化它,因为你不需要RestOf..
类别我得到这样的东西:
WITH
SET [AllCities] AS [Markets].[City].MEMBERS
//SET [AllPRODUCTS] AS NONEMPTY([Product].[Product].MEMBERS, [Measures].[Sales])
//alternative if NonEmpty not implemented in Mondrian..
SET [AllPRODUCTS] AS
FILTER(
[Product].[Product].MEMBERS
,not isEmpty([Measures].[Sales])
)
SET [Top5PRODUCTS] AS
Generate
(
[AllCities]
,TopCount
(
(EXISTING
[AllPRODUCTS])
,5
,[Measures].[Sales]
)
)
SELECT
NON EMPTY
{[Measures].[Sales]} ON COLUMNS
,
[AllCities]
*[Top5PRODUCTS]
ON ROWS
FROM [SteelWheelsSales];
谢谢。不幸的是,这个脚本不适用于我的Pentaho - Saiku Analytics界面(使用mondrian 3模式)。错误是:MondrianException:Mondrian错误:第11行第11列的语法错误标记'[AllPRODUCTS]'。 - 看起来NONEMPTY()和EXISTING在SET中不被接受。我用FILTER()函数替换它,然后[Top5PRODUCTS]集返回0行。 –
@ElizaM是否在Mondrian内实施?这个配方取决于它的功能。 – whytheq
SET在mondrian中没有实现EXISTING。 “MondrianException:Mondrian错误:第17行第11列的语法错误,标记'[AllPRODUCTS]'” –