我正在使用销售多维数据集。
我想按年度获得前五名商店,并在报告中按季度显示其销售额。
我能够获得前五名的商店,但不仅是季度,而且还有季度!
SELECT NON EMPTY { [Measures].[Revenue] } ON COLUMNS,
NON EMPTY { ([DWH REF DATE].[H_CALENDER].[QUARTER NUM].ALLMEMBERS * TOPCOUNT([DWH REF STORE].[H_STORE].[STORE].ALLMEMBERS , 5 , [Measures].[Revenue] )) }
DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_VALUE, MEMBER_UNIQUE_NAME ON ROWS FROM ( SELECT ( -{ [DWH REF STORE].[H_STORE].[TERRITORY].&[N/A].&[N/A] } ) ON COLUMNS FROM ( SELECT ( { [DWH REF DATE].[H_CALENDER].[YEAR NUM].&[2012] } ) ON COLUMNS FROM [SALES CUBE]))
我真正希望能够做到的是按年获得前5名商店,并按5家商店中的四分之一获得销售额。
答案 0 :(得分:1)
欢迎使用SO,因此让我们看一个例子。 我试图从2013年Adventureworks多维数据集的互联网销售中获得前5名副产品
select
[Measures].[Internet Sales Amount]
on columns,
non empty
topcount
(
[Product].[Subcategory].[Subcategory],
5,
[Measures].[Internet Sales Amount]
)
on rows
from
[Adventure Works]
where [Date].[Calendar].[Calendar Year].&[2013]
现在让我们尝试按季度划分那里的销售额
select
[Measures].[Internet Sales Amount]
on columns,
non empty
[Date].[Calendar Quarter of Year].[Calendar Quarter of Year]
on rows
from
(select topcount([Product].[Subcategory].[Subcategory],5,[Measures].[Internet Sales Amount]) on 0 from [Adventure Works] )
where [Date].[Calendar].[Calendar Year].&[2013]
结果
编辑:基于评论
select
[Measures].[Internet Sales Amount]
on columns,
non empty
(
topcount
(
[Product].[Subcategory].[Subcategory],
5,
[Measures].[Internet Sales Amount]
),[Date].[Calendar Quarter of Year].[Calendar Quarter of Year])
on rows
from
[Adventure Works]
where [Date].[Calendar].[Calendar Year].&[2013]