MDX IIF always evaluates to second argument

  • Hi everyone,

    I am stuck in this situation and it is getting the better of me. This should be obvious and easy but I am seeing a weird behavior with mdx iif statement. Irrespective of the condition(1st argument), it always evaluates to the second argument. Below is a code snippet -

    THIS = IIF ([Item].[Price Segment].CurrentMember IS [Item].[Price Segment].&[L],

    IIF ([Measures].[Month Rolling JOD] > 0.19,1, NULL),

    IIF ([Measures].[Month Rolling JOD] > 0.32, 1, NULL)

    );

    In the above code, irrespective of [Price Segment] value, it evaluates the second argument. I thought this to be an issue with the comparison so I tried different ways.

    2nd way -

    THIS = IIF ([Item].[Price Segment].MemberValue = 'L',

    IIF ([Measures].[Month Rolling JOD] > 0.19,1, NULL),

    IIF ([Measures].[Month Rolling JOD] > 0.32, 1, NULL)

    );

    3rd way -

    THIS =

    CASE [Item].[Price Segment].MemberValue

    WHEN 'L' THEN

    IIF ([Measures].[3 Month Rolling POD] > 0,19,1, NULL)

    ELSE

    IIF ([Measures].[3 Month Rolling POD] > 0.32 1, NULL)

    END ;

    In all the ways, it is always 2nd argument that is evaluated. Even if [Item].[Price Segment] is L.

    This is a SOS situation. Any help is greatly appreciated folks.

  • HOpe this helps --> link

    Steve.

  • Thanks for your response steve. I had read thepost earlier and tried to use membervalue already if you notice my code snippet. Even that does not seem to resolve the issue ..

  • I saw that but to me it looks like you have used one part of the solution and then the other part of the solution but never both parts together. Current member and member value.

    Steve.

  • Okay, so I tried below as well with the same results. Not sure if there could be something more to it. To me it looks to be a simple ternary operator which should evaluate 2nd argument if the [Price Sgment] value is L. If not it should evaluate the 3rd argument. Here, it is always evaluating the 3rd argument.

    THIS = IIF ([Item].[Price Segment].CurrentMember.MemberValue = 'L',

    IIF ([Measures].[Month Rolling JOD] > 0.19, 1, NULL),

    IIF ([Measures].[Month Rolling JOD] > 0.32,1, NULL)

    );

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply