我想在 MDX 查询中按数量和平均成本对客户进行排名。但是,当我使用以下查询时:
WITH
SET TiedRanksbyVol AS
ORDER( [Dim Customer].[Customer Category].[Customer Category].Members, [Measures].[Quantity], BDESC)
SET TiedRanksbyAvgCost AS
ORDER( [Dim Customer].[Customer Category].[Customer Category].Members, [Measures].[AvgCost], BDESC)
MEMBER [Measures].[TIED_RANKbyVol] AS
RANK( [Dim Customer].[Customer Category].CURRENTMEMBER, TiedRanksbyVol, [Measures].[Quantity])
MEMBER [Measures].[TIED_RANKbyAvgCost] AS
RANK( [Dim Customer].[Customer Category].CURRENTMEMBER, TiedRanksbyAvgCost, [Measures].[AvgCost])
SELECT
NOT EMPTY
{
[Measures].[Quantity],
[Measures].[TIED_RANKbyVol],
[Measures].[AvgCost],
[Measures].[TIED_RANKbyAvgCost]
} ON COLUMNS
NOT EMPTY
{
TiedRanksbyVol
} ON ROWS
FROM cube
结果集如下所示:
*************************************************************|
|Quantity |TIED_RANKbyVol| AvgCost| TIED_RANKbyAvgCost|
Alliaz | 26 | 1 | 128 | 4 |
AXER | 25 | 2 | 225 | 1 |
Global | 20 | 3 | 200 | 3 |
Direct | 5 | 4 | 210 | 2 |
**************************************************************
我得到没有 Null 的排名。但是当我向 ROWS 添加一个维度时,如下所示,我在返回集中得到空值
SET TiedRanksbyAvgCost AS
ORDER( [Dim Customer].[Customer Category].[Customer Category].Members, [Measures].[AvgCost], BDESC)
MEMBER [Measures].[TIED_RANKbyVol] AS
RANK( [Dim Customer].[Customer Category].CURRENTMEMBER, TiedRanksbyVol, [Measures].[Quantity])
MEMBER [Measures].[TIED_RANKbyAvgCost] AS
RANK( [Dim Customer].[Customer Category].CURRENTMEMBER, TiedRanksbyAvgCost, [Measures].[AvgCost])
SELECT
NOT EMPTY
{
[Measures].[Quantity],
[Measures].[TIED_RANKbyVol],
[Measures].[AvgCost],
[Measures].[TIED_RANKbyAvgCost]
} ON COLUMNS
NOT EMPTY
{([Dim Product].[Product].[Product].MEMBERS *
TiedRanksbyVol)
} ON ROWS
FROM cube
结果集如下所示:
********************************************************************|
|Quantity |TIED_RANKbyVol| AvgCost| TIED_RANKbyAvgCost|
Bikes |Alliaz | 26 | 1 | 128 | 4 |
Bikes |Alliaz | (null) | 2 | (null) | 3 |
Cups |AXER | 25 | 3 | 225 | 1 |
Cups |AXER | (null) | 2 | (null) | 1 |
Marks |Global | 20 | 3 | 200 | 3 |
Marks |Global | (null) | 3 | (null) | 3 |
Towel |Direct | 5 | 4 | 210 | 2 |
Towel |Direct | (null) | 4 | (null) | 2 |
********************************************************************
结果集有 (null) 并且把排名弄乱了。如何从结果集中删除空值,以确保行和度量上有多个维度,并在列上进行排名。任何帮助将不胜感激。