14 Replies Latest reply on Jun 12, 2018 11:46 AM by hakris

    ELSEIF condition




      Summarizing the Issue

      for example a script is having IF and ELSEIF both (like the script I mentioned)... Now while execution if IF condition comes out to be true, would ELSEIF be igoned? by being ignored I mean the further part of script from ELSEIF will not be processed.



      Explaining in my actual scenario:

      I have few members starting from Request_1, Request_2, Request_3 and so on... using a variable for this in below script {Request}


      Trying to make something where business rule should give an error if the user has not filled up previous request number so that all the request numbers can be used sequentially.


      IF( @ISMBR(Request_1))

      Allow to input Request;

      ELSEIF (@Member(@Previoussibling({Request})) == #missing)

      @Return("Please use the previous request number", ERROR)




      If the business rule is run on Request_2, it works fine. IF condition is not met, and script takes the member Request_1 for ELSEIF. Hence, performs as expected.


      But if the same is run for Request_1, IF condition should be met and it should end processing any further script. But in this case it gives me error on the line number having ELSEIF condition. This indicates that @Member(@Previoussibling({Request})) is trying to search a member before Request_1. As there's no member before Request_1 it gives error. Now my question is in this case as the IF condition has already been met, why even ELSEIF condition is being read? If that condition is not read while execution it can work as expected.



        • 1. Re: ELSEIF condition



          I did not get the requirement completely, but the logic of IF is sequentially.

          So the test if the previous request is missing or not needs to come first. If  this fails, you give the message. If not, you go on.


          I would work with @PRIOR and do the range with a FIX.. ENDFIX.





          Philip Hulsebosch.

          • 2. Re: ELSEIF condition

            Thanks for replying.... ok simply....


            for example a script is having IF and ELSEIF both (like the script I mentioned)... Now while execution if IF condition comes out to be true, would ELSEIF be igoned? by being ignored I mean the further part of script from ELSEIF will not be processed.

            • 3. Re: ELSEIF condition


              You might want to take a look at this.



              Not sure how your calculation is structured. But above describes whether a block is being calculated or just a cell.


              Thanks, Pawan.

              • 4. Re: ELSEIF condition

                Thanks, it was very informative.


                But my question is bit different. If the IF condition has been passed as true, then ELSEIF or ELSE shouldn't be processed?


                Cell and Block calcmode deal with if the calculations within these above conditions are dependent or not. So that's a different thing. Thanks.

                • 5. Re: ELSEIF condition
                  Teresa Modesta

                  Recently I advised someone else that IF you have a long IF elseif block then you can get some serious performance gains by having the IF first that is most likely to be true, it massively cuts down the processing time, so from this I can confidently state that IF the IF is true it does not evaluate the else ifs, you can test this yourself by writing a statement where the IF is always true and see how it massively cuts the processing time down on a lengthy elseif chain of logic.

                  • 6. Re: ELSEIF condition

                    Thank you so much...


                    I 100% agree and i have the same experience. If the first condition is met then rule doesn't go further it stops right there. But I have a script where if the IF condition is met, the ELSEIF condition by syntax will become invalid. So I thought if IF condition is met then script will not read ELSEIF and I won't get any error. But despite the IF condition is met, script still gives me an error while reading ELSEIF condition (Please note I'm referring to ELSEIF condition, not the calculation that happens on being True).


                    Further in my script, if the IF condition is not met, then ELSEIF is read, gives no error, and also turns out to be True. The problem is if IF condition is met, then it should not give me any error because of ELSEIF Condition.

                    • 7. Re: ELSEIF condition
                      Teresa Modesta

                      What exactly do you mean by 'the syntax will become invalid', can you give a brief example of exactly what you mean?

                      • 8. Re: ELSEIF condition

                        That is correct.

                        Your FIX statement determines what is going to be evaluated in the IF.. ELSEIF..

                        In all these database tuples from the FIX, there will be cases where the IF Statement is true and then the ELSEIF Statement is not considered. But very likely,there will be tuples which give a false to the IF statement and will go further into the ELSEIF and maybe into the ELSE.

                        Otherwise the IF statement would not make sense.





                        Philip Hulsebosch


                        • 9. Re: ELSEIF condition

                          Let's say I have few members starting as Member 1, Member 2 Member 3 and so on.... Now I want to have a different calculation for Member 1 and a different calculation if that's any member other than Member 1. I have created a variable to select these members in business rule, say, {Member_Var}


                          1.   FIX({Member_Var})

                          2.   IF(@ISMBR("Member1")

                          3.   A = B + C;

                          4.   ELSEIF ( @Membeer(@prevsibling({Member_Var} == #missing))

                          5.   A = D + E

                          6.   ENDIF


                          If the value of member being calculated is "Member 1" it gives error on line 4 because this string couldn't find a member before "Member 1". But if the same script is run for "Member 2" it exectues the line 5 meaning it passed through condition in line 4. I thought when "Member 1" is selected the ELSEIF at line 4 will not be read at all and so will not give any error.


                          Even now it's difficult to understand, then I can post my actual script or can make a video demonstrating this issue.


                          Regards and Thanks,

                          Adnan Arshad.

                          • 10. Re: ELSEIF condition
                            Teresa Modesta

                            I understand what you are saying and I think that the entire syntax has to be valid, even if the first IF condition should mean that the second ELSEIF is not evaluated because the IF is True.


                            This is similar to if you try;


                            Fix (Jan:May)




                            --something here




                            --something else here





                            Logically you would think this would compile, with the second fix yielding nothing at runtime, but what happens is that it does not compile...

                            • 11. Re: ELSEIF condition
                              Julien Mallet

                              Actually the problem is that the condition in your ELSEIF is not properly written. @PREVSIBLING returns a string, and you use @MEMBER which returns a member name, it can't be compared with Missing. Do you really need that condition and not just use ELSE?

                              If yes try to rewrite it with @SHIFT or @PRIOR.

                              • 12. Re: ELSEIF condition

                                Can you try and return the member name in Elseif condition


                                @return(@name(@currmbr(request))),error) and check what exactly it returns.

                                • 13. Re: ELSEIF condition

                                  Yes, i need condition.


                                  I tried @shift, it gives error

                                  • 14. Re: ELSEIF condition



                                    I have seen this issue earlier and the issue is because of the combination of @Member and @PrevSibling functions. If the selected RTP is first member then @PrevSibling will return "null" whereas @member can not process "null". So during run time, you will get an error


                                    It doesn't matter whether you have given @prevsibiling in IF condition or in ELSE condition


                                    I would suggest, for this requirement don't go with the @Prevsibling function. Instead, use some other dimension member as flag and check the condition