我想查询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)
当尺寸成员按数字排列时,可以使用下面的表达式
在哪里([Dim公司信息]。[Gdp增长]。&3:[Dim公司信息]。[Gdp增长]。&3 .LastChild),并稍有修正
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]