1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
WITH
MEMBER [Measures].[Rank]
AS
Rank
(
[Product].[Model Name].CurrentMember,
[Product].[Model Name].[Model Name],
[Measures].[Order Count]
)
SET [Sorted Models]
AS
Order
(
[Product].[Model Name].[Model Name]
,[Measures].[Order Count]
,BDESC
)
MEMBER [Measures].[Previous Model Index]
AS
(
Rank
(
[Product].[Model Name].CurrentMember,
[Sorted Models]
)
-
2
)
MEMBER [Measures].[Dense Rank]
AS
Case
When [Measures].[Rank] = 1
Then 1
Else
(
[Sorted Models].Item([Measures].[Previous Model Index]),
[Measures].[Dense Rank]
)
+
Iif
(
(
[Sorted Models].Item([Measures].[Previous Model Index]),
[Measures].[Order Count]
)
=
[Measures].[Order Count]
,0
,1
)
End
SELECT
{
[Measures].[Rank],
[Measures].[Dense Rank]
}
ON 0,
{
[Sorted Models]
}
ON 1
FROM [Adventure Works] |
Partager