如何在MDX中根据维度值实现"greater than"

How to implement "greater than" based on dimension value in MDX

我想查询每个GDP增长率大于3的国家的销售总额,目前可以这样显示每个国家的销售信息:

SELECT 
{[Measures].[Sales]} ON 0,
{[Dim Company Info].[LOC].ALLMEMBERS} ON 1
FROM [Database]

但是我仍然对如何查询所有超过 3 的 GDP 增长率一无所知。我搜索了 SO 并找到了过滤器作为答案,但是,我不知道在上面的代码中将它包含在哪里.我该怎么做?

编辑:我尝试了以下方法,但我认为这不是我应该做的:

WHERE ([Dim Company Info].[Gdp Growth].&[3] : [Dim Company Info].[Gdp Growth].&[3].LastChild)

SELECT 
{[Measures].[SALES]} ON 0,
{FILTER([Dim Company Info].[LOC].MEMBERS, [Dim Company Info].[Gdp Growth] > 3)} ON 1
FROM [766 Database]

SELECT 
{[Measures].[SALES]} ON COLUMNS,
{[Dim Company Info].[LOC].MEMBERS} ON ROWS
FROM [766 Database]
WHERE FILTER([Dim Company Info].[Gdp Growth], [Dim Company Info].[Gdp Growth] > 2)

当维度成员按数字排列时,您可以使用下面的表达式

WHERE ([Dim Company Info].[Gdp Growth].&3 : [Dim Company Info].[Gdp Growth].&3.LastChild) with a slight correction

WHERE ([Dim Company Info].[Gdp Growth].&[3] : [Dim Company Info].[Gdp Growth].[Gdp Growth].LastChild)

但是如果不是这样,那么你需要按照下面的方法。

我正在报告最大数量的产品。

select {[Measures].[Internet Sales Amount]} on 0,
non empty
([Product].[Product].[Product],[Promotion].[Max Quantity].[Max Quantity]) on 1 
from [Adventure Works]

现在让我们操纵最大数量,使其表现得像一个度量。

with 
member measures.test
as 
case when [Measures].[Internet Sales Amount]>0 then 
(nonempty(([Product].[Product].currentmember,[Promotion].[Max Quantity].[Max Quantity]),[Measures].[Internet Sales Amount])).item(0).item(1).name
else 
null end

select
{[Measures].[Internet Sales Amount],measures.test}
on 0,
non empty ([Product].[Product].[Product] )
on 1 
from [Adventure Works]

现在你可以使用过滤器了,但是我们还需要转换(注意CInt的使用)数据

with 
member measures.test
as 
case when [Measures].[Internet Sales Amount]>0 then 
Cint((nonempty(([Product].[Product].currentmember,[Promotion].[Max Quantity].[Max Quantity]),[Measures].[Internet Sales Amount])).item(0).item(1).name)
else 
null end

select
{[Measures].[Internet Sales Amount],measures.test}
on 0,
non empty (
filter(
[Product].[Product].[Product]
,measures.test>0) 
)
on 1 
from [Adventure Works]