使用
TopCount
功能如下:
select
{
[Measures].[Quantity],
[Measures].[Net Sales]
}
on columns,
NON EMPTY
TopCount([Products].[Item Description].children * [Calendar].[Date].[Date],
3,
[Measures].[Quantity])
on rows
from
(
select
{
[Calendar].[Date].&[2015-03-23T00:00:00],
[Calendar].[Date].&[2015-03-22T00:00:00],
[Calendar].[Date].&[2015-03-21T00:00:00]
}
ON columns
FROM [SalesReport])
要获取每个日期的前3条记录,您可以使用
GENERATE
功能:
select
{
[Measures].[Quantity],
[Measures].[Net Sales]
}
on columns,
NON EMPTY
GENERATE([Calendar].[Date].[Date],
TopCount([Products].[Item Description].children,
3,
[Measures].[Quantity])
)
on rows
from
(
select
{
[Calendar].[Date].&[2015-03-23T00:00:00],
[Calendar].[Date].&[2015-03-22T00:00:00],
[Calendar].[Date].&[2015-03-21T00:00:00]
}
ON columns
FROM [SalesReport])