获取不同年份MDX的前5名

问题描述 投票:0回答:1

我有一个按年份排列的前5名客户,我想创建一个查询,在不同的年份同时获得这些信息,我的意思是。

select 
[Measures].[Ventas] 
on columns,
non empty
topcount
(
[Dim Cliente].[Company Name].Children,5,[Measures].[Ventas]
) 
on rows
from 
[DWH Northwind]
where 

[Dim Tiempo].[Año].&[1996]

1996年的前5名

TOP 5 1996

我可以得到1996年和1997年的前5名一起分开每年?

sql-server ssas mdx mdxstudio mdxclient
1个回答
3
投票

你可以使用 生成 功能如下。

select 
  [Measures].[Ventas] on columns,

  non empty Generate(
    { [Dim Tiempo].[Año].&[1995], [Dim Tiempo].[Año].&[1996] } as yy,
    topcount (yy.currentMember * [Dim Cliente].[Company Name].Children,5,[Measures].[Ventas]) 
  ) on rows

from [DWH Northwind

这样你就可以用同样的方法 检索出每个可用年份的前五名。

select 
  [Measures].[Ventas] on columns,

  non empty Generate(
    [Dim Tiempo].[Año].members as yy,
    topcount (yy.currentMember * [Dim Cliente].[Company Name].Children,5,[Measures].[Ventas]) 
  ) on rows

from [DWH Northwind

希望对你有帮助


1
投票

试试这个

select 
[Measures].[Ventas] 
on columns,
non empty
{
topcount
(([Dim Tiempo].[Año].&[1996],[Dim Cliente].[Company Name].Children),5,[Measures].[Ventas]) 
,
topcount
(([Dim Tiempo].[Año].&[1997],[Dim Cliente].[Company Name].Children),5,[Measures].[Ventas]) 
}
on rows
from 
[DWH Northwind]
where 
© www.soinside.com 2019 - 2024. All rights reserved.