Essbase Calc Script IF/ELSEIF Issue

So I’ve been working on a 20,000+ line business rule in Planning. Yes, for real. It’s not a complicated script, it’s just repetitive due to using values from a Smart List. It’s quite simple – depending on the month and the cost center they will be moving to, copy over the employee details for the remainder of the year to the new cost center while retaining values in the old cost center up to the point of transfer. However, the script would keep wiping the data. I knew it was working because when I tested only for copying of data, I had values in both cost centers. However, when I added the second section to clear the data in the old cost center, the entire year’s data was wiped, not just the old cost center data months. How frustrating.

Here’s what I discovered…

Here is my test worksheet. The bottom part of the sheet has the original data. The top is the new cost center that data is supposed to copy to.

Original

Here is my original script. Note that if the conditions are met, 2 actions are to take place.

2

However, when I run the script, all monthly data gets wiped. You can see that my TransferMonth and TransferToCC values are still intact.

3

I had a hypothesis that it was running the second action even if the conditions were not met. To test, I replaced the #Missing with 412. Sure enough, it was happening.

4

5

However, when I removed the second action from the IF/ELSEIF statement, it ran just fine. (Note that I separated out both actions to different scripts and it worked perfectly.)

6

So, in short, I had to write double the code to get the data to copy and then to clear from the old cost center.

So let me pose a question…does Essbase take a second action item in an IF/ELSEIF statement to be an ELSE statement instead? From my research, it appears that way, but I couldn’t find anything definitive in the Essbase Tech Ref. The closest I found was how Essbase treats IF versus ELSE calculations (that it calculates for the IF/ELSEIF items before the ELSE), but nothing about multiple items below an IF/ELSEIF statement.

Moral of the story? Only one action item per IF/ELSEIF condition set.

7 comments

  1. I am making an assumption that Once the Begbalance->Transfer month == 1 is fulfilled the employee needs to be transferred and second condition is just to check which entity the data needs to be transferred to. Have you tried creating an IF within IF condition

    Eg. IF( Begbalance->Transfer month == 1)
      IF(Begbalance->ToCC==1)
        XXXX=&VarEntity
      ELSEIF(Begbalance->ToCC==2)
        XXXX=&VarEntity
      ENDIF
      &VarEntity=#missing
        ELSEIF( Begbalance->Transfer month == 2)
      IF(Begbalance->ToCC==1)
        XXXX=&VarEntity
      ELSEIF(Begbalance->ToCC==2)
        XXXX=&VarEntity
      ENDIF
      &VarEntity=#missing
      ENDIF
    In this case it should finish the “if” conditions before clearing the data.You might have already tried this option. Let me know your thoughts.

  2. It’s not that you can only do one operation per IF/ELSEIF, it’s that (I’m speculating here) both of your statements are being executed “simultaneously”, not sequentially as you might imagine. The following calc script from Sample.Basic illustrates what’s going on. If you set Florida to 1 and run it, both New York and Massachusetts get updated with the correct values. If you set Florida to 2, both Massachusetts and Connecticut end up as #MI no matter what value is originally in Connecticut. If you set Florida to 3 then both Massachusetts and Connecticut are set to 500 even if Connecticut is not 500 to begin with. Very quirky IMHO…

    //ESS_LOCALE English_UnitedStates.Latin1@Binary

    SET UPDATECALC OFF;
    SET AGGMISSG ON;

    FIX(“Jan”,”COGS”,”100-10″){
    “Actual”(
    IF(“Florida” == 1)
    “New York” = “Connecticut”;
    “Massachusetts” = “New Hampshire”;
    ELSEIF(“Florida” == 2)
    “Massachusetts” = “Connecticut”;
    “Connecticut” = #MISSING;
    ELSEIF(“Florida” == 3)
    “Massachusetts” = “Connecticut”;
    “Connecticut” = 500;
    )
    }

    1. Tim…I think you are onto something. I put in a third action item and it appears these items are running simultaneously as, logically, the calc script doesn’t tell it what to do what it is doing. However, when you mash them all together, it makes sense.

  3. That can’t be right. Do you get more specific later on about which months to copy, based on the value of TransferMonth? Are you equally specific about which months you clear? From what I can see, I’d lay it at the doorstep of not FIXing on Period. (Whatever it is, Essbase understands how to do an IF with multiple lines, for sure.)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s