问题描述
我想在 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].[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].[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 |
********************************************************************
结果集有(空)并且弄乱了排名。 如何从结果集中删除空值以确保我在行和度量上有多个维度并在列上进行排名。 任何帮助将不胜感激。
解决方法
在 Rows 部分尝试更严格的 NONEMPTY
:
...
NOT EMPTY
{ NONEMPTY(
[Dim Product].[Product].[Product].MEMBERS * TiedRanksbyVol,[Measures].[Quantity] )
} ON ROWS
...