我需要在SSAS cube
中将 null 替换为 0 。实现这个目标的正确方法是什么?
这是我目前的查询:
SELECT {([Measures].[Employee Age Count])}
ON COLUMNS, { ([Dim Gender].[Gender Name].[Gender Name].ALLMEMBERS *
[Dim Age Ranges].[Age Range ID].[Age Range ID].ALLMEMBERS ) } ON ROWS
FROM ( SELECT ( { [Dim Location].[Location].[Location Grp Name].&[BOSTON] }) ON COLUMNS
FROM [People Dashboard])
WHERE ( [Dim Location].[Location].[Location Grp Name].&[BOSTON] )
当前查询的结果:
答案 0 :(得分:3)
我认为IIF(ISEMPTY...
非常标准。
我还通过删除相当多的大括号来简化你的脚本。还将逻辑从子选择中移出到基本的WHERE
子句中:
WITH MEMBER [Measures].[MEASURE_NONEMPTY] AS
IIF(
ISEMPTY([Measures].[Service Period Count])
,0
,[Measures].[Service Period Count]
)
SELECT
{[Measures].[MEASURE_NONEMPTY]} ON 0,
[Dim Gender].[Gender Name].[Gender Name].ALLMEMBERS
* [Dim Age Ranges].[Age Range ID].[Age Range ID].ALLMEMBERS
ON 1
FROM [People Dashboard]
WHERE [Dim Location].[Location].[Location Grp Name].&[BOSTON]
;
答案 1 :(得分:0)
WITH MEMBER [Measures].[MEASURE_NONEMPTY] AS COALESCEEMPTY([Measures].[Service Period
Count], 0)
SELECT {[Measures].[MEASURE_NONEMPTY]} ON COLUMNS, { ([Dim Gender].[Gender Name].[Gender
Name].ALLMEMBERS * [Dim Age Ranges].[Age Range ID].[Age Range ID].ALLMEMBERS )
} ON ROWS FROM ( SELECT ( { [Dim Location].[Location].[Location Grp Name].&
[BOSTON] } ) ON COLUMNS FROM [People Dashboard]) WHERE ( [Dim Location].
[Location].[Location Grp Name].&[BOSTON] )
我使用上面的代码来解决问题。
答案 2 :(得分:-1)
我还没有测试,但如果有效,你可以尝试下面的方法,
SELECT {COALESCE (([Measures].[Employee Age Count]),"0") as AgeCount}
ON COLUMNS, { ([Dim Gender].[Gender Name].[Gender Name].ALLMEMBERS *
[Dim Age Ranges].[Age Range ID].[Age Range ID].ALLMEMBERS ) } ON ROWS
FROM ( SELECT ( { [Dim Location].[Location].[Location Grp Name].&[BOSTON] }) ON COLUMNS
FROM [People Dashboard])
WHERE ( [Dim Location].[Location].[Location Grp Name].&[BOSTON] )