在 MDX 中相交 Select 查询
Intersect Select Query in MDX
我希望在两个 mdx 查询中有客户交集。
1.
SELECT
[Measures].[Cs] ON 0
,NonEmpty([Customers].[Customer].MEMBERS) ON 1
FROM [sfe cube]
WHERE
(
[Calend].[Period].&[201506]
,[Customers].[BP Territory].&[38UZ1]
,[Materials].[Brand].&[Coca-Cola]
);
2.
SELECT
[Measures].[Cs] ON 0
,NonEmpty([Customers].[Customer].MEMBERS) ON 1
FROM [sfe cube]
WHERE
(
[Calend].[Period].&[201506]
,[Customers].[BP Territory].&[38UZ1]
,[Materials].[Brand].&[Fanta Orange CSD]
);
我尝试的 mdx
脚本:
SELECT
{} ON COLUMNS,
INTERSECT(
( Select [Measures].[Cs] on 0,
nonempty([Customers].[Customer].members) on 1
from [sfe cube]
WHERE ([Calend].[Period].&[201506]
,[Customers].[BP Territory].&[38UZ1]
,[Materials].[Brand].&[Coca-Cola])
)
,
( Select [Measures].[Cs] on 0,
nonempty([Customers].[Customer].members) on 1
from [sfe cube]
WHERE ([Calend].[Period].&[201506]
,[Customers].[BP Territory].&[38UZ1]
,[Materials].[Brand].&[Fanta Orange CSD]))
) ON ROWS
FROM [sfe cube]
当我运行查询时出现错误:
Subselect only support axis COLUMNS.
我做错了什么?
你的语法乱七八糟!检查 INTERSECT
here.
的语法
我获得 "common" 客户的方式如下:
WITH SET CommonCustomers AS
INTERSECT(
NonEmpty(
[Customers].[Customer].members,
(
[Calend].[Period].&[201506],
[Customers].[BP Territory].&[38UZ1],
[Materials].[Brand].&[Coca-Cola]
) * [Measures].[Cs]
)
,
NonEmpty(
[Customers].[Customer].members,
(
[Calend].[Period].&[201506],
[Customers].[BP Territory].&[38UZ1],
[Materials].[Brand].&[Fanta Orange CSD]
) * [Measures].[Cs]
)
)
SELECT {} ON COLUMNS,
CommonCustomers ON ROWS
FROM [sfe cube]
你可以为 AND
逻辑实现这样的东西:
WITH
SET [YourSet] AS
NonEmpty
(
NonEmpty
(
{[Customers].[Customer].MEMBERS}
,{[Materials].[Brand].&[Fanta Orange CSD]}
)
,{[Materials].[Brand].&[Coca-Cola]}
)
SELECT
[Measures].[Cs] ON 0
,NON EMPTY [YourSet] ON 1
FROM [sfe cube]
WHERE
(
[Calend].[Period].&[201506]
,[Customers].[BP Territory].&[38UZ1]
);
使用 Exists
的不同变体(我更喜欢)在 post:
中有详细说明
MDX query to calculate measure with AND condition by members from same dimension
我喜欢 sourav 对我们的想法 intersect
。我认为他的脚本可以稍微简化为:
WITH
SET CommonCustomers AS
Intersect
(
NonEmpty
(
[Customers].[Customer].MEMBERS
,[Materials].[Brand].&[Coca-Cola]
)
,NonEmpty
(
[Customers].[Customer].MEMBERS
,[Materials].[Brand].&[Fanta Orange CSD]
)
)
SELECT
{[Measures].[Cs]} ON COLUMNS
,NON EMPTY
CommonCustomers ON ROWS
FROM [sfe cube]
WHERE
(
[Calend].[Period].&[201506]
,[Customers].[BP Territory].&[38UZ1]
);
我希望在两个 mdx 查询中有客户交集。
1.
SELECT
[Measures].[Cs] ON 0
,NonEmpty([Customers].[Customer].MEMBERS) ON 1
FROM [sfe cube]
WHERE
(
[Calend].[Period].&[201506]
,[Customers].[BP Territory].&[38UZ1]
,[Materials].[Brand].&[Coca-Cola]
);
2.
SELECT
[Measures].[Cs] ON 0
,NonEmpty([Customers].[Customer].MEMBERS) ON 1
FROM [sfe cube]
WHERE
(
[Calend].[Period].&[201506]
,[Customers].[BP Territory].&[38UZ1]
,[Materials].[Brand].&[Fanta Orange CSD]
);
我尝试的 mdx
脚本:
SELECT
{} ON COLUMNS,
INTERSECT(
( Select [Measures].[Cs] on 0,
nonempty([Customers].[Customer].members) on 1
from [sfe cube]
WHERE ([Calend].[Period].&[201506]
,[Customers].[BP Territory].&[38UZ1]
,[Materials].[Brand].&[Coca-Cola])
)
,
( Select [Measures].[Cs] on 0,
nonempty([Customers].[Customer].members) on 1
from [sfe cube]
WHERE ([Calend].[Period].&[201506]
,[Customers].[BP Territory].&[38UZ1]
,[Materials].[Brand].&[Fanta Orange CSD]))
) ON ROWS
FROM [sfe cube]
当我运行查询时出现错误:
Subselect only support axis COLUMNS.
我做错了什么?
你的语法乱七八糟!检查 INTERSECT
here.
我获得 "common" 客户的方式如下:
WITH SET CommonCustomers AS
INTERSECT(
NonEmpty(
[Customers].[Customer].members,
(
[Calend].[Period].&[201506],
[Customers].[BP Territory].&[38UZ1],
[Materials].[Brand].&[Coca-Cola]
) * [Measures].[Cs]
)
,
NonEmpty(
[Customers].[Customer].members,
(
[Calend].[Period].&[201506],
[Customers].[BP Territory].&[38UZ1],
[Materials].[Brand].&[Fanta Orange CSD]
) * [Measures].[Cs]
)
)
SELECT {} ON COLUMNS,
CommonCustomers ON ROWS
FROM [sfe cube]
你可以为 AND
逻辑实现这样的东西:
WITH
SET [YourSet] AS
NonEmpty
(
NonEmpty
(
{[Customers].[Customer].MEMBERS}
,{[Materials].[Brand].&[Fanta Orange CSD]}
)
,{[Materials].[Brand].&[Coca-Cola]}
)
SELECT
[Measures].[Cs] ON 0
,NON EMPTY [YourSet] ON 1
FROM [sfe cube]
WHERE
(
[Calend].[Period].&[201506]
,[Customers].[BP Territory].&[38UZ1]
);
使用 Exists
的不同变体(我更喜欢)在 post:
MDX query to calculate measure with AND condition by members from same dimension
我喜欢 sourav 对我们的想法 intersect
。我认为他的脚本可以稍微简化为:
WITH
SET CommonCustomers AS
Intersect
(
NonEmpty
(
[Customers].[Customer].MEMBERS
,[Materials].[Brand].&[Coca-Cola]
)
,NonEmpty
(
[Customers].[Customer].MEMBERS
,[Materials].[Brand].&[Fanta Orange CSD]
)
)
SELECT
{[Measures].[Cs]} ON COLUMNS
,NON EMPTY
CommonCustomers ON ROWS
FROM [sfe cube]
WHERE
(
[Calend].[Period].&[201506]
,[Customers].[BP Territory].&[38UZ1]
);