计算测量值的非空函数

时间:2014-02-24 20:42:33

标签: reporting-services ssas mdx

我写了一个计算的度量如下

With member [Measures].[Path] as 
Iif (condition, DisplayIteration, null)


Select [Measures].[Path] ,
[Measures].[Caption],
[Measures].[Value] on 0 , 
{NonEmpty 
(
Crossjoin (
[Item].[Product],
Descendants ([Item].[Iteration])
)
, Descendants ([Item].[Iteration])
)
}on 1 from [Item]

[Measures]。[Path]是报告参数标签和[Measures]。[Value]是报告参数值。由于过滤器应用于后代([Item]。[Iteration],[Measures]。[Path]的空值仍然可见。有没有办法解决这个问题?

2 个答案:

答案 0 :(得分:0)

作为非空的替代,你可以尝试使用MeasureGroupName参数的exists()。度量的NullProcessing属性可能未设置为“保留”

您可以查看以下主题:

http://social.msdn.microsoft.com/Forums/sqlserver/en-US/f5ee3df4-3fc7-44ff-9248-c5a3a384ea4e/exists-vs-nonempty?forum=sqlanalysisservices

菲利普,

答案 1 :(得分:0)

我认为有两种可能性可以满足您的要求:

使用[Measures].[Path]作为NonEmpty的第二个参数:

With member [Measures].[Path] as 
Iif (condition, DisplayIteration, null)

Select [Measures].[Path] ,
[Measures].[Caption],
[Measures].[Value] on 0 , 
{NonEmpty 
(
Crossjoin (
[Item].[Product],
Descendants ([Item].[Iteration])
)
, { [Measures].[Path] }
)
}on 1 from [Item]

或使用HAVING代替NonEmpty,这可能会对条件更具选择性:

With member [Measures].[Path] as 
Iif (condition, DisplayIteration, null)

Select [Measures].[Path] ,
[Measures].[Caption],
[Measures].[Value] on 0 , 
Crossjoin (
[Item].[Product],
Descendants ([Item].[Iteration])
)
Having Not [Measures].[Path] Is null
on 1 from [Item]

我不确定对结果或性能的正确性有何影响,您必须对此进行测试。

相关问题