我有一个MDX查询我已经挣扎了一段时间,似乎无法让它飞得正确!痛点是子查询试图只接受那些具有任何状态但仍处于“关闭”状态的工作(DIM项目)。[工作状态]。& [关闭]}。我知道/我认为我可能在某个地方遗漏了一个括号???
MAybe第二眼会帮助???
SELECT
NON EMPTY
{
[Measures].[Estimate Extended Amount]
,[Measures].[Estimate Line Total]
,[Measures].[Estimate Markup Amount]
} ON COLUMNS
,NON EMPTY
{
[DIM PROJECT].[Client - Division - Product - Component].[Job Component Number].ALLMEMBERS*
[DIM PROJECT].[Component Description].[Component Description].ALLMEMBERS*
[DIM PROJECT].[Client PO Number].[Client PO Number].ALLMEMBERS*
[DIM PROJECT].[Job Status].[Job Status].ALLMEMBERS*
[DIM PROJECT].[Project Start Date].[Project Start Date].ALLMEMBERS*
[DIM PROJECT].[Project End Date].[Project End Date].ALLMEMBERS*
[DIM FUNCTION].[Function Category].[Function Category].ALLMEMBERS*
[DIM ESTIMATE].[Estimate Number].[Estimate Number].ALLMEMBERS*
[DIM ESTIMATE].[Estimate Status].[Estimate Status].ALLMEMBERS
}
DIMENSION PROPERTIES
MEMBER_CAPTION
,MEMBER_UNIQUE_NAME
ON ROWS
FROM
(
SELECT
{[DIM ESTIMATE].[Estimate Status].&[Approved]} ON COLUMNS
FROM (-{[DIM PROJECT].[Job Status].&[Closed]} ON COLUMNS
(
SELECT
StrToSet
(@DIMPROJECTProduct
,CONSTRAINED
) ON COLUMNS
FROM
(
SELECT
StrToSet
(@DIMPROJECTDivision
,CONSTRAINED
) ON COLUMNS
FROM
(
SELECT
StrToSet
(@DIMPROJECTClient
,CONSTRAINED
) ON COLUMNS
FROM [ESTIMATES]
)
)
)
)
WHERE
(
IIF
(
StrToSet
(@DIMPROJECTClient
,CONSTRAINED
).Count
= 1
,StrToSet
(@DIMPROJECTClient
,CONSTRAINED
)
,[DIM PROJECT].[Client].CurrentMember
)
,IIF
(
StrToSet
(@DIMPROJECTDivision
,CONSTRAINED
).Count
= 1
,StrToSet
(@DIMPROJECTDivision
,CONSTRAINED
)
,[DIM PROJECT].[Division].CurrentMember
)
,IIF
(
StrToSet
(@DIMPROJECTProduct
,CONSTRAINED
).Count
= 1
,StrToSet
(@DIMPROJECTProduct
,CONSTRAINED
)
,[DIM PROJECT].[Product].CurrentMember
)
)
CELL PROPERTIES
VALUE
,BACK_COLOR
,FORE_COLOR
,FORMATTED_VALUE
,FORMAT_STRING
,FONT_NAME
,FONT_SIZE
,FONT_FLAGS;
答案 0 :(得分:2)
我不太确定你要做什么,但似乎你可能会使你的查询变得复杂一些。我认为您正在寻找的功能是:
Except([DIM PROJECT].[Job Status].[All].Children,[DIM PROJECT].[Job Status].&[Closed])
除了关闭之外,这将为您提供所有工作状态。如果你将它放在你的where子句中(简化为ymmv),它可能会显示为:
SELECT
NON EMPTY
{
[Measures].[Estimate Extended Amount]
,[Measures].[Estimate Line Total]
,[Measures].[Estimate Markup Amount]
} ON COLUMNS
,NON EMPTY
{
[DIM PROJECT].[Client - Division - Product - Component].[Job Component Number].ALLMEMBERS*
[DIM PROJECT].[Component Description].[Component Description].ALLMEMBERS*
[DIM PROJECT].[Client PO Number].[Client PO Number].ALLMEMBERS*
[DIM PROJECT].[Job Status].[Job Status].ALLMEMBERS*
[DIM PROJECT].[Project Start Date].[Project Start Date].ALLMEMBERS*
[DIM PROJECT].[Project End Date].[Project End Date].ALLMEMBERS*
[DIM FUNCTION].[Function Category].[Function Category].ALLMEMBERS*
[DIM ESTIMATE].[Estimate Number].[Estimate Number].ALLMEMBERS*
[DIM ESTIMATE].[Estimate Status].&[Approved]
}
DIMENSION PROPERTIES
MEMBER_CAPTION
,MEMBER_UNIQUE_NAME
ON ROWS
FROM [ESTIMATES]
WHERE
( StrToSet(@DIMPROJECTProduct),
StrToSet(@DIMPROJECTDivision),
StrToSet(@DIMPROJECTClient),
Except([DIM PROJECT].[Job Status].[All].Children,[DIM PROJECT].[Job Status].&[Closed]))
如果你的参数碰巧是单个成员,你可以在where子句中使用StrToMember。