如果我有两个尺寸:原点和目的地,我如何计算原点=目的地的次数?
SELECT [Location] ON COLUMNS
FROM [DELIVERIES]
WHERE ( [Origin] = [Destination] )
[Origin] = [Destination]显然不是答案......
以下代码生成正确的结果:
SELECT
SUM(Transfers) AS Same_Skill_Transfers
FROM (
SELECT
CONVERT(varchar(30),"[From VQ].[LOB].[LOB].[MEMBER_CAPTION]") As From_VQ,
CONVERT(varchar(30),"[To VQ].[LOB].[LOB].[MEMBER_CAPTION]") As To_VQ,
CONVERT(integer,"[Measures].[Transfers]") As Transfers
FROM
OPENQUERY(TRANSFERS,'
SELECT
{[Measures].[Transfers]} ON COLUMNS,
Filter(NonEmptyCrossjoin( [From VQ].[LOB].Members, [To VQ].[LOB].Members),
[From VQ].[LOB].[LOB].[Life Cycle].Properties(''Caption'') = [To VQ].[LOB].[LOB].[Life Cycle].Properties(''Caption'')
) ON 1
FROM
[Transfers]
WHERE (
[Date].[Date Hierarchy].[Month].[July 2014],
[From VQ].[Hierarchy].[AOB].[Consumer],
[From Agent].[Employee Id].&[612117]
)
')
) A
WHERE
To_VQ = From_VQ
假设我有[FROM_VQ]。[LOB] =“BOTH”并且我希望在[FROM_VQ]时包含在SUM中。[LOB] =“Both”和[TO_VQ]。[LOB]是A还是B?
答案 0 :(得分:3)
您的问题缺少一些信息,但我会采取刺,然后在您提供更多信息后进行更新。我假设有两个维度,原点和目的地,并且每个维度都有一个位置属性。
通常,您可以为此使用过滤器语句。如果您的location属性在每个维度中具有相同的键,则可以执行以下操作:
select [Origin].[Location].children on 0,
Filter(NonEmptyCrossjoin( [Origin].[Location].Children, [Destination].[Location].Children),
[Origin].[Location].Properties('Key') = [Destination].[Location].Properties('Key')
) on 1 from [DELIVERIES]
如果键不相同,但您在该字段中看到的标签是您可以切换标题键。
Here's一个例子,有人用日期做了这个。