简体   繁体   中英

Non-empty function on calculated Measure

I wrote a calculated measure as follows

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]

The [Measures].[Path] is a report parameter label and [Measures].[Value] is a report parameter value. Since the filter is applied over Descendants ([Item].[Iteration] the null values of [Measures].[Path] are still seen. Is there any way to fix this?

As an alternative to non empty, u can try exists() with MeasureGroupName parameter. The NullProcessing property of the measure may not be set to Preserve

You might have a look at the following thread:

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

Philip,

I see two possibilities to approach your requirement:

Either use [Measures].[Path] as the second argument to 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]

or use HAVING instead of NonEmpty , which can be more selective on the condition:

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]

I am not sure about the effects on correctness of the result or performance, you will have to test that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM