我是MDX的新手,你们中的任何人都可以帮我解决下面的问题吗?
1)从上面的结果集中,如何消除column1&中具有空值的行。 column3使用以下查询。
WITH
MEMBER TotalPatientCnt as '[Measures].[HealthPlanPatientCnt]'
MEMBER PrevalencePercent as '([Measures].[PatientCnt]*1.00/[Measures]. [TotalPatientCnt])*100'
SELECT
NON EMPTY {[DimCP_Population].[Dr Key].[Dr Key]}
ON rows,
{
[Measures].[PatientCnt] ,[Measures].[TotalPatientCnt]
,[Measures].[PrevalencePercent]
}
ON columns
FROM [StrategyCompanionDWCube]
WHERE
(
[DimAnchorDate].[Date Key].&[20121231],
[DimCP_PCP].[PCP Key].&[124],
[DimProduct].[Product Key].&[15],
[DimHealthPlan].[Health Plan Key].&[1]
)
2)我有3个维度&分别采取3项措施
[DimCP_PCP], [DimProduct], [DimHealthPlan]
pcpCnt, productCnt, HelahtPlanPatientCnt
我想基于具有参数值的维度类型构建相同的TotalPatientCnt
成员,希望需要编写case语句但我无法编写case语句请帮助我们以下示例。
WITH MEMBER TotalPatientCnt as
case
when [DimProduct].[Product Key].&[if getting anymember] then
'[Measures].[productCnt]'
when [DimHealthPlan].[Health Plan Key].&[if getting anymember] then
'[Measures].[HealthPlanPatientCnt]'
when [DimCP_PCP].[PCP Key].&[if getting anymember] then
'[Measures].[pcpCnt]'
如果我从[DimCP_PCP]
获取任何参数,例如[DimCP_PCP].[PCP Key].&[124]
需要显示TotalPatientCnt成员,如下所示
WITH MEMBER TotalPatientCnt as '[Measures].[pcpCnt]'
如果我从[DimHealthPlan]
得到任何参数,例如[DimHealthPlan].[Health Plan Key].&[1]
需要显示TotalPatientCnt
成员,如下所示
WITH MEMBER TotalPatientCnt as '[Measures].[HealthPlanPatientCnt]'
如果我从[DimProduct]
示例[DimProduct].[Product Key].&[15]
获得任何参数需要显示TotalPatientCnt
成员,如下所示
WITH MEMBER TotalPatientCnt as '[Measures].[productCnt]'
答案 0 :(得分:3)
回答你的第一个问题:
由于NON EMPTY
对此处的行不起作用,因为要排除的记录的第二列不为空,您可以使用很少记录的HAVING
子句,如下所示:
...
{[DimCP_Population].[Dr Key].[Dr Key]}
HAVING NOT IsEmpty([Measures].[PatientCnt])
AND NOT IsEmpty([Measures].[PrevalencePercent])
ON rows
...
答案 1 :(得分:0)
SELECT
(
[DimAnchorDate].[Date Key].&[20121231],
[DimCP_PCP].[PCP Key].&[124],
[DimProduct].[Product Key].&[15],
[DimHealthPlan].[Health Plan Key].&[1],
[Measures].[PatientCnt],
[Measures].[TotalPatientCnt]
,[Measures].[PrevalencePercent]
) On 0,
NON EMPTY {[DimCP_Population].[Dr Key].[Dr Key]}
ON 1
FROM [StrategyCompanionDWCube]
OR
Understand the difference between NON-EMPTY vs Nonempty()
在这里,您可能会得到答案并明确NULL和EMPTY的概念