我有一个抛出错误的MDX查询-“在交叉连接功能中多次使用了portalID层次结构”
查询在where子句失败
WHERE
(-{[SG Location].[PortalID].[30],
[SG Location].[PortalID].[46]},
[SG Location].[PortalID].[4],
[SG Program].[Campaign].&[*Cymbalta_Lilly (111)],
[Prints],
[SG Location].[IsTest].[0]
)
在上面的where子句中动态附加了以下条件(排除少数门户)
-{[SG Location].[PortalID].[30],
[SG Location].[PortalID].[46]}
请帮助!我是MDX查询的新手。真的很感谢与MDX查询相关的任何有用链接-特别是where子句。
下面是完整的MDX查询
WITH
MEMBER [SG Date].[Day].[TotPrintCount] AS
SUM(
{
[SG Date].[Day].&[2018-06-15],
[SG Date].[Day].&[2018-06-16],
[SG Date].[Day].&[2018-06-17],
[SG Date].[Day].&[2018-06-18]
},
[Measures].[Prints]
)
MEMBER [SG Date].[Day].[TotCustRev] AS
SUM(
{
[SG Date].[Day].&[2018-06-15],
[SG Date].[Day].&[2018-06-16],
[SG Date].[Day].&[2018-06-17],
[SG Date].[Day].&[2018-06-18]
},
[Measures].[CustRev]
)
MEMBER [SG Date].[Day].[TotLDMRev] AS
SUM(
{
[SG Date].[Day].&[2018-06-15],
[SG Date].[Day].&[2018-06-16],
[SG Date].[Day].&[2018-06-17],
[SG Date].[Day].&[2018-06-18]
},
[Measures].[LDMRev]
)
MEMBER [Measures].[RevRatio] AS [Measures].[LDMRev] / [Measures].[Transactions] * 1000
MEMBER [Measures].[MatchRatio] AS SUM([Measures].[PaidPrints]) / SUM([Measures].[Transactions]) * 100
SELECT {
[SG Date].[Day].[TotPrintCount],
[SG Date].[Day].&[2018-06-15],
[SG Date].[Day].&[2018-06-16],
[SG Date].[Day].&[2018-06-17],
[SG Date].[Day].&[2018-06-18],
[SG Date].[Day].[TotCustRev],
[SG Date].[Day].[TotLDMRev]}
ON COLUMNS, NON EMPTY
{
{ [SG Location].[Hierarchy].[Portal].ALLMEMBERS } * { [SG Program].[Hierarchy].ALLMEMBERS }
} ON ROWS FROM [ScriptGuide]
WHERE
(-{[SG Location].[PortalID].[30],
[SG Location].[PortalID].[46]},
[SG Location].[PortalID].[4],
[SG Program].[Campaign].&[*Cymbalta_Lilly (111)],
[Prints],
[SG Location].[IsTest].[0]
)
答案 0 :(得分:0)
您应该做的是不要多次使用层次结构。但是从您的陈述来看,它是“动态添加的”,我假设它是由另一个模块完成的,并且各个模块协调其层次结构过滤器是一个问题。在这种情况下,请创建一个子查询,如下所示:
WITH
(...)
SELECT
(...)
FROM (
SELECT (-{[SG Location].[PortalID].[30], [SG Location].[PortalID].[46]}) on 0 FROM [ScriptGuide]
)
WHERE
(
[SG Location].[PortalID].[4],
[SG Program].[Campaign].&[*Cymbalta_Lilly (111)],
[Prints],
[SG Location].[IsTest].[0]
)
我们在这里所做的是将默认PortalID排除项放到FROM下的子查询中。该查询将首先执行,因此主查询不会将其视为冲突。
如果它是全局(或至少是全球通用的)PortalID删除过滤器-将其推送到子查询中很有意义。