如何将 where 子句编码为计算成员?

How to code a where clause into a calculated member?

第一个查询符合我的需要。但是当我尝试根据计算成员重写以将​​其放入我的多维数据集时,它崩溃了。

select non empty [Measures].[Demanda Real] on 0,
non empty [Agente Distribuidor].[Nombre Distribuidor].[Nombre Distribuidor].members on 1
from Demanda
where [SkSubmercadoUsuario]

First MDX query results

这是我失败的尝试:

with member [Measures].[Demanda Real Dos] 
as
([Measures].[Demanda Real], [SkSubmercadoUsuario])
select [Measures].[Demanda Real Dos]  on 0,
non empty [Agente Distribuidor].[Nombre Distribuidor].[Nombre Distribuidor].members on 1
from Demanda

我需要的是通过 [SkSubmercadoUsuario] 对我的立方体进行切片,但不能通过 where 子句。我需要创建一个度量,通过这个命名集 [SkSubmercadoUsuario]

对度量进行切片

我不确定你想做什么。 您只想在查询中创建第二个度量 [Measures].[Demanda Real] 重命名为 [Measures].[Demanda Real Dos] 还是想在多维数据集的 "calculation script part" 中创建度量? 在第一种情况下,我认为您不需要移动条件部分。试试这个:

with member [Measures].[Demanda Real Dos] 
as
([Measures].[Demanda Real])
select [Measures].[Demanda Real Dos]  on 0,
non empty [Agente Distribuidor].[Nombre Distribuidor].[Nombre Distribuidor].members on 1
from Demanda
where [SkSubmercadoUsuario]

可能你需要做这样的事情

with member [Measures].[Demanda Real Dos] 
as
SUM({[Sk Submercado Usuario].&[52], [Sk Submercado Usuario].&[622]}, 
     [Measures].[Demanda Real] )

select [Measures].[Demanda Real Dos]  on 0,
non empty [Agente Distribuidor].[Nombre Distribuidor].[Nombre Distribuidor].members on 1
from Demanda