3

I am trying to produce a different output in a column dependent on whether the value of a dimension [Scenario].[Option] is +5 which I've tried to achieve using the IIf function.

WITH MEMBER [XorY] AS
(
    IIf([Scenario].[Option] = +5, 'X', 'Y')
    --IIf([Scenario].[Option].&[+5], 'X', 'Y')
)
SELECT
NON EMPTY
(
    [Scenario].[Option].[Option]
) ON ROWS,
NON EMPTY
(
    [XorY]
) ON COLUMNS
FROM [RePro]
WHERE
(
    [ABC].[ABC].[Val]
) CELL PROPERTIES VALUE

However, using either of the IIf statements as above, [XorY] is always Y regardless of the value of [Scenario].[Option]. It seems the comparison I'm doing is just syntactically wrong or something. How do I do this? I've noticed it works much better if I use a calculated member in a [Measures] dimension in the IIf condition, but that is not possible in my case - I must use [Scenario].[Option].

Thanks for any help received :)

4

1 回答 1

5

当您使用成员语句时,您通常希望使用 currentmember,因为它引用当前单元格。将其与 membervalue 结合起来,您将获得价值。在这种情况下,我将预期的答案用引号括起来。

WITH MEMBER [XorY] AS
(
   IIf([Scenario].[Option].currentMember.membervalue = "+5", 'X', 'Y')
)

如果您要与一个数字进行比较,您会这样做:

WITH MEMBER [XorY] AS
(
   IIf(STRTOVALUE([Scenario].[Option].currentMember.membervalue) = 5, 'X', 'Y')
)

如果不是 [Scenario].[Option] 中的所有成员都是数字,这可能会返回错误。转换还存在潜在的性能问题。

于 2013-10-02T17:03:35.477 回答