我有一个定义了小时维度的多维数据集和一个名为numberofoccurrances的事实表中的列。如何获得每天发生值的最大出现次数和小时数。我尝试了以下内容
SELECT [Measures].[numberofoccurrances] ON 0,
TOPCOUNT([Hour].[Hour].MEMBERS, 1, [Measures].[numberofoccurrances])
ON 1
FROM [all_measurements]
它找到最大值发生的小时,但总结该小时的所有值并返回错误的值。
有没有办法在两列中获得每天最大值的一小时?
您需要使用rank()和filter函数。看看下面的例子。
下面的查询列出了一年中的互联网销售额
SELECT
{[Measures].[Internet Sales Amount]} ON COLUMNS,
non empty ({[Date].[Calendar Year].[CY 2011],[Date].[Calendar Year].[CY 2012],[Date].[Calendar Year].[CY 2013]},[Date].[Month of Year].[Month of Year])
ON ROWS
FROM
[Adventure Works]
现在将这些月份排在几年之内,并先过滤它们
WITH
MEMBER [Measures].[Monthly_Ranking_InternetSales] AS
RANK( [Date].[Month of Year].CurrentMember,
ORDER( [Date].[Month of Year].[Month of Year].Members , [Measures].[Internet Sales Amount], BDESC)
)
SELECT
{[Measures].[Internet Sales Amount]} ON COLUMNS,
non empty
filter( ({[Date].[Calendar Year].[CY 2011],[Date].[Calendar Year].[CY 2012],[Date].[Calendar Year].[CY 2013]},
ORDER ([Date].[Month of Year].[Month of Year], [Measures].[Monthly_Ranking_InternetSales] , BASC )
),[Measures].[Monthly_Ranking_InternetSales] <2)
ON ROWS
FROM
[Adventure Works]
结果