Skip to Content
author's profile photo Former Member
Former Member

logic script IF_ELSE

Hi Expert,

It is possible to apply IF ......ELSE function in my logic script

logic script example:

*WHEN PLANITEM

*IS SP121004

*REC(EXPRESSION=%VALUE%,PLANITEM=#temp1) --> line 1

*IS MC120090

*REC(EXPRESSION=%VALUE%,PLANITEM=#temp1) --> line 2

*ENDWHEN //planitem

In this example wish to REC only ONCE.... either line 1 or line 2

If line 1 is excute then skip line 2

If line 1 is not excute then excute line 2

Any idea how to do this??

Thanks..

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Sep 29, 2010 at 08:27 AM

    Hi,

    You can try using an MDX formula. Have a look at the various examples of MDX formulas:

    [PLANITEM].[TEMP1] = iif ([PLANITEM].currentmember.name="SP121004", [PLANITEM].[SP121004],)

    Hope this helps.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi nilanjan chatterjee,

      I do have some error from the first part of my logic script before *GO

      I just no idea how to get correct #temp1 I want..

      What I want is...

      something like

      if( PLANITEM (SP121004) <> 0)

      *REC(EXPRESSION=GET(PLANITEM="SP121004"),PLANITEM=#temp1) --> get value from SP121004

      ELSE

      *REC(EXPRESSION=GET(PLANITEM="MC120090"),PLANITEM=#temp1) --> get value from MC120090

      so ..I am try to ask solution from you see you have any idea or method to meet what I exactly I want.

      hope you can understand....

  • author's profile photo Former Member
    Former Member
    Posted on Sep 29, 2010 at 02:01 PM

    I am not sure I understand exactly, but the *WHEN is the *IF..ELSE command in SQL logic. Using you example...

    *WHEN PLANITEM

    *IS SP121004

    *REC(EXPRESSION=%VALUE%,PLANITEM=#temp1) --> line 1

    *IS MC120090

    *REC(EXPRESSION=%VALUE%,PLANITEM=#temp1) --> line 2

    *ENDWHEN //planitem

    For each record in scope it will look at the PLANITEM dimension ID, if it is SP121004 it will execute the first REC statment. If it is not then it will see if it is MC120090 and it true then execute the next statement.

    If you always want it to do the second statement so for any planitem not SP121004 then change your code to the following:

    *WHEN PLANITEM

    *IS SP121004

    *REC(EXPRESSION=%VALUE%,PLANITEM=#temp1) --> line 1

    *ELSE

    *REC(EXPRESSION=%VALUE%,PLANITEM=#temp1) --> line 2

    *ENDWHEN //planitem

    Now the second REC statment is executed for all non-SP121004 items and the first rec statement is for all SP121004 records.

    *WHEN PLANITEM

    *IS SP121004

    *REC(EXPRESSION=%VALUE%,PLANITEM=#temp1) --> line 1

    *IS MC120090

    *REC(EXPRESSION=%VALUE%,PLANITEM=#temp1) --> line 2

    ELSE

    *REC()

    *ENDWHEN //planitem

    This could be used if you wanted to have condiditions for SP121004 and MC120090 and then all other line items.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 29, 2010 at 02:12 PM

    Hello,

    We recommend script logic over MDX because many customers face performance problems when using MDX. You can use a WHEN/ENDWHEN container, and justify each logical case to do what you intend to do. It may seem time consuming, but programming in that manner will give a better outcome.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.