MDX - 即使没有可用数据,也始终返回至少一行

时间:2014-07-23 06:53:15

标签: reporting-services mdx

我使用以下MDX来提取参数:

WITH
    MEMBER [Measures].[Label] AS [Dim].[Hier].CURRENTMEMBER.NAME
    MEMBER [Measures].[Value] AS [Dim].[Hier].CURRENTMEMBER.UNIQUENAME

SELECT
{
    [Measures].[Label]
    , [Measures].[Value]
}
ON 0,
    NONEMPTY([Dim].[Hier].children, [Measures].[Measure])
ON 1
FROM [Cube]
WHERE 
(
-- Criteria
)

有时,在选择某些过滤条件时,查询会产生空集。相反,我希望它在值和标签中都显示“N / A”。它在MDX中是可行的,还是应该使用SSRS计算成员来计算结果数据集中的行并替换?

1 个答案:

答案 0 :(得分:3)

类似的东西:

WITH
 SET [MySet] AS  NONEMPTY([Dim].[Hier].children, [Measures].[Measure])
 MEMBER [Measures].[Label] AS [Dim].[Hier].CURRENTMEMBER.NAME
 MEMBER [Measures].[Value] AS [Dim].[Hier].CURRENTMEMBER.UNIQUENAME
 MEMBER [Dim].[Hier].[All(likely)].[N/A] AS 'N/A'
SELECT
 {[Measures].[Label] , [Measures].[Value] }
ON 0,
 IIF( count( [MySet] ) = 0, {[Dim].[Hier].[All(likely)].[N/A]}, [MySet] )
ON 1
FROM
 [Cube]
WHERE 
 (-- Criteria)