Date calculation script

Hi,
I need to calculate difference between two dates. I believe that i should use function @DATEDIFF to perform such a calculation.
But the problem that one of the dates calculated by such a script:
i=@TODATEEX("Month dd yyyy",@CONCATENATE(@CONCATENATE(@NAME(@CURRMBR("Current Period"))," 01 "),@NAME(@ALIAS({RTP_Year}))));
i=(@DATEPART(i,DP_YEAR)*100 + @DATEPART(i,DP_MONTH))*100+ @DATEPART(i,DP_DAY);
This script returns first day of currently selected month and planning period (RTP_Year - financial year).
And when i try to perfom calculation between variable i and member i ends whith error. Could you suggest something?
I also tried some work arounds suggested in other threads but whithout success. I use 1.1.2.1.

Hi,
Try this:
Re: Days behaviour between two dates
Cheers,
Alp

Similar Messages

  • How to Flip the Sign using Calculation script for historical data

    I am currently using Essbase 9.3.1. Its required to flip sign for a specific set of accounts for that i am currently using UDA's to flip the sign.
    But now i need to flip the sign for the historical data too. Is there any possible way to flip the sign using calculation scripts for historical data. Kindly let me know your suggestions.
    Many thanks in Advance...
    Edited by: [email protected] on Jul 30, 2009 9:37 PM
    Edited by: [email protected] on Jul 30, 2009 10:58 PM
    Edited by: [email protected] on Jul 30, 2009 11:01 PM

    Of course there is. This is the kind of calc script that only gets run once, so make usre you test it well before doing it on production and make a backup of production before doing it.
    It would be something like
    Fix(time frame, accounts to be flipped, level zero other dimensions)
    actual = actual * -1;
    EndFix
    Cal dim dimensions
    Note, I chose actual, but you could do it for any dimension that has a single or only a couple of members. What ever dimension you choose to do the calculation on, it can't be included in the fix statement

  • Calculation Script on page 2 with data from page 1?

    I am missing something simple here.. I am wanting to write a calculation script using the sum of two numeric fields on page one divided by the sum of two numeric fields on page two. The only thing I can get to work is if I do a numeric field on page one and do the sum calculation there. Then if I move it down to page two it is just blank. What am I missing?

    Hi,
    You can achieve this, you just need to reference the fields properly.
    First, make sure that you have named both pages. Leaving pages/subforms (and objects) unnamed makes it more difficult to reference in script.
    There is a handy trick when you are in the Script Editor. Hover the mouse over another object and press/hold Control. The mouse will change into a 'V'. Still holding Control click the object, and LC Designer will insert the reference into the script. This is easy enough when the objects are close, so do a bit of practice. If the objects on are on different pages, then you need to scroll down to the object you want to reference, activate the Script Editor again and then click the object with Control held.
    Here is an example for referencing objects: http://www.assuredynamics.com/index.php/category/portfolio/referencing-objects/
    Hope that helps,
    Niall
    Assure Dynamics

  • Which is faster -  Member formula or Calculation script?

    Hi,
    I have a very basic question, though I am not sure if there is a definite right or wrong answer.
    To keep the calculation scripts to a minimum, I have put all the calculations in member formula.
    Which is faster - Member formula or calculation scripts? Because, if i am not mistaken, FIX cannot be used in member formulas, so I need to resort to the use of IF, which is not index driven!
    Though in the calculation script,while aggregating members which have member formula, I have tried to FIX as many members as I can.
    What is the best way to optimize member formulas?
    I am using Hyperion Planning and Essbase 11.1.2.1.
    Thanks.

    Re the mostly "free" comment -- if the block is in memory (qualification #1), and the formula is within the block (qualification #2), the the expensive bit was reading the block off of the disk and expanding it into memory. Once that is done, I typically think of the dynamic calcs as free as the amount of data being moved about is very, very, very small. That goes out the window if the formula pulls lots of blocks to value and they get cycled in and out of the cache. Then they are not free and are potentially slower. And yes, I have personally shot myself in the foot with this -- I wrote a calc that did @PRIORS against a bunch of years. It was a dream when I pulled 10 cells. And then I found out that the client had reports that pulled 5,000. Performance when right down the drain at that point. That one was 100% my fault for not forcing the client to show me what they were reporting.
    I think your reference to stored formulas being 10-15% faster than calc script formulas deals with if the Formulas are executed from within the default calc. When the default Calc is used, it precompiles the formulas and handles many two pass calculations in a single pass. Perhaps that is what you are thinking of.^^^I guess that must be it. I think I remember you talking about this technique at one of your Kscope sessions and realizing that I had never tried that approach. Isn't there something funky about not being able to turn off the default calc if a user has calc access? I sort of thing so. I typically assing a ; to the default calc so it can't do anything.
    Regards,
    Cameron Lackpour

  • Which is faster - Member formula or Calculation scripts?

    Hi,
    I have a very basic question, though I am not sure if there is a definite right or wrong answer.
    To keep the calculation scripts to a minimum, I have put all the calculations in member formula.
    Which is faster - Member formula or calculation scripts? Because, if i am not mistaken, FIX cannot be used in member formulas, so I need to resort to the use of IF, which is not index driven!
    Though in the calculation script,while aggregating members which have member formula, I have tried to FIX as many members as I can.
    What is the best way to optimize member formulas?
    I am using Hyperion Planning and Essbase 11.1.2.1.
    Thanks.

    The idea that you can't reference a member formula in a FIX is false. Here's an example:
    - Assume you have an account that has a data storage of Stored or Never Share.
    - This account is called Account_A and it has a member formula of Account_B * Account_C;.
    - You would calculate this account within a FIX (inside of a business rule) something like this:
    FIX(whatever . . . )
    "Account_A";
    ENDFIX
    If you simply place the member named followed by a semi-colon within a business rule, the business rule will execute the code in the in that member's member formula.
    Why would you want to do this instead of just putting ALL of the logic inside the business rule? Perhaps that logic gets referenced in a LOT of different business rules, and you want to centralize the code in the outline? This way, if the logic changes, you only need to update it in one location. The downside to this is that it can make debugging a bit harder. When something doesn't work, you can find yourself searching for the code a bit.
    Most of my applications end up with a mix of member formulas and business rules. I find that performance isn't the main driving force behind where I put my code. (The performance difference is usually not that significant when you're talking about stored members.) What typically drives my decision is the organization of code and future maintenance. It's more art than science.
    Hope this helps,
    - Jake

  • Custom calculation script for checkboxs

    Hello,
    Can anyone help me out with custom calculation script for this?  I have two mutually exclusive checkboxes that, when checked, I want to populate data into other text fields.
    If Checkbox1 is checked:
    Company1=Warehouse Alpha
    Address1=1234 Any Street
    City/State/Zip1= Los Angeles, CA 90020
    Contact Name1= Mr. Nice Guy
    Phone Number1= 213-854-8565
    Email1=[email protected]
    If Checkbox2 is checked:
    Company2=Warehouse Beta
    Address2= 5678 Awesome Blvd.
    City/State/Zip2= San Bernardino, CA 96545
    Contact Name2= Mr. Handsome
    Phone Number2= 909-824-8265
    Email2=[email protected]
    Thanks,
    Bryan

    So one has two check boxes and one wants them to be mutually exclusive. Name them the same and change the export value of the field. Try it and observe what happens as you check the different check boxes.
    You have described what happens if either box is checked but what happens when a checked box Is unckecked?
    One can place scripts in many locations. I would use a mouse up action for both the check boxes, use the same script for both check boxes.
    I would assume you are using the following names for the fields to populate:
    Company
    Address
    CityStateZip
    ContactName
    PhoneNumber
    Email
    // Mouse up action for both check boxes;
    // initial value for the fields:
    this.getField("Company"),value = "";
    this.getField("CityStateZip"),value = "";
    this.getField("ContactName"),value = "";
    this.getField("PhoneNumber"),value = "";
    this.getField("Email"),value = "";
    // test for check box value for selected box;
    if(event.value == 1) {
    this.getField("Company"),value = "Warehouse Alpha";
    this.getField("CityStateZip"),value = "1234 Any Street";
    this.getField("ContactName"),value = "Los Angeles, CA 90020";
    this.getField("PhoneNumber"),value = "213-854-8565";
    this.getField("Email"),value = "[email protected]";
    if(event.value == 2) {
    this.getField("Company"),value = "Warehouse Beta";
    this.getField("CityStateZip"),value = "5678 Awesome Blvd.";
    this.getField("ContactName"),value = "San Bernardino, CA 96545";
    this.getField("PhoneNumber"),value = "Mr. Handsome";
    this.getField("Email"),value = "[email protected]";
    // end Mouse up action for both check boxes;

  • Custom Calculation Script - Multiplication IF

    Hey Adobe peeps, need help here. I'm not a programmer by any stretch of the imagination, but I am resourceful, BUT I have yet to find a concrete answer for this, nor can I get any of my test formula's to work.
    I have a fillable PDF that is used in a field service environment where employees track their time. I want them to be able to input the data in i.e. hours*rate and it automatically populate the price/cost. Now this is very easy to do with the built in product function, but the problem here is that they have multiple fields to fill out. See below.....
    So basically the "Extended Price" field depends on what they enter into either the "Days", "ST Hours", "Rate, "OT Hours" or "Rate" fields.
    The calculation should be based on 2 of the 5 fields being filled out. For example, here are the 3 possible scenarios:
    Scenario 1: SP Extended Price1=SP Days1*SP ST Rate1
    Scenario 2: SP Extended Price1=SP ST Hours1*SP ST Rate1
    Scenario 3: SP Extended Price1=SP OT Hours1*SP OT Rate1
    They won't ever fill out any more than 2 of the fields so it needs to be an 'if' type of function. I've spent hours on this already, like I said, I'm not a programmer.
    Please help.

    If they really won't be filling in more than one of those sets of fields, the custom calculation script could be:
    (function () {
        // Get the field values, as strings
        var s1 = getField("SP Days1").valueAsString;
        var s2 = getField("SP ST Rate1").valueAsString;
        if (s1 && s2) {
            event.value = +s1 * +s2;
            return;
        var s3 = getField("SP ST Hours1").valueAsString;
        if (s2 && s3) {
            event.value = +s3 * +s2;
            return;
        var s4 = getField("SP OT Hours1").valueAsString;
        var s5 = getField("SP OT Rate1").valueAsString;
        if (s4 && s5) {
            event.value = +s4 * +s5;
            return;
        // If none of these apply, set the field to blank
        event.value = "";

  • Problem in picking the system variable value in Calculation Script

    Hi All,
    We are using a Calculation Script to perform data export. And the target location where to crete the exported output file is given to the environment system variable.
    Now I am using this system variable in the calculation script as below:
    //ESS_LOCALE English_UnitedStates.Latin1@Binary
    SET DATAEXPORTOPTIONS
    DataExportLevel "ALL";
    DataExportOverwriteFile ON;
    Fix ( &CurrMiles, &CurrProj, &CurrVer,"No Project","No Version")
    DATAEXPORT "File" " " $DEXPORTPATH;
    ENDFIX
    Here "DEXPORTPATH" is the system variable
    I am creating this system variable from the batch script and the system variable value varies at the runtime.
    This calculation script works fine for first time and it picks the correct value from the system variable.
    But the problem occurs from next execution of calc script. Even if i update the system variable with other value, it picks only the last execution system variable value and it performs execution.
    Eg: Suppose for first execution system variable value is "D:\Bkup\PMV.txt"
    The calc script works fine with this.
    For next execution, system variable value is changed to "D:\Time\temp.txt"
    Now the calc script picks the system variable value as "D:\Bkup\PMV.txt"
    and performs execution which is wrong.
    Please help me on this issue how to handle system variables in calc scripts.
    Thanks in advance
    Regards
    Swathi

    811829 wrote:
    Hi All,
    We are using a Calculation Script to perform data export. And the target location where to crete the exported output file is given to the environment system variable.
    Now I am using this system variable in the calculation script as below:
    //ESS_LOCALE English_UnitedStates.Latin1@Binary
    SET DATAEXPORTOPTIONS
    DataExportLevel "ALL";
    DataExportOverwriteFile ON;
    Fix ( &CurrMiles, &CurrProj, &CurrVer,"No Project","No Version")
    DATAEXPORT "File" " " $DEXPORTPATH;
    ENDFIX
    Here "DEXPORTPATH" is the system variable
    I am creating this system variable from the batch script and the system variable value varies at the runtime.
    This calculation script works fine for first time and it picks the correct value from the system variable.
    But the problem occurs from next execution of calc script. Even if i update the system variable with other value, it picks only the last execution system variable value and it performs execution.
    Eg: Suppose for first execution system variable value is "D:\Bkup\PMV.txt"
    The calc script works fine with this.
    For next execution, system variable value is changed to "D:\Time\temp.txt"
    Now the calc script picks the system variable value as "D:\Bkup\PMV.txt"
    and performs execution which is wrong.
    Please help me on this issue how to handle system variables in calc scripts.
    Thanks in advance
    Regards
    SwathiAs of my knowledge system variables will not update immediately...you need to log off the session after changing the value.
    Update the system variable..
    Log off from the session..
    And Re-login with the same username ....and check...
    Regards,
    Prabhas

  • I'm getting an error 1012016 on my calculation script

    Good day guys,
    I just wanted to ask for your opinion as I'm getting this error:
    Cannot calculate dimension member DimX with restricted member ChildrenX1_1.
    Here's the scenario. I have a dimension, DimX and under this dimension, i have 3 children DimX_1, DimX_2, and DimX_3. Now, upon roll up, DimX should only get the value of DimX_3 for actual data, and get the sum of DimX_1 and DimX_3 for all the forecast.
    Now the current structure of this dimension is:
    DimX
    -----DimX_1 ( + )
    ----------ChildrenX1_1
    -----DimX_2 ( ~ )
    ----------ChildrenX2_1
    -----DimX_3 ( + )
    ----------ChildrenX3_1
    Now I have this calculation script:
    FIX(Actual)
    DimX = DimX_3;
    ENDFIX;
    Now upon execution of the calculation, I get the error above. Can you please tell me what's wrong with this simple script?
    Thank you very much.
    Edited by: 26FEB1986 on Jul 9, 2010 8:30 PM
    Edited by: 26FEB1986 on Jul 9, 2010 8:30 PM

    I think the member ChildrenX1_1 is in the fix of Upper portion of the script.
    L.H.S in the formula should be with in the range of Fix criteria
    Remove the ChildrenX1_1 from the Fix or come out of the range.
    You can write like this.
    FIX(DimX)
    FIX(Actual)
    DimX_3;
    ENDFIX;
    ENDFIX;
    You have to run this calc after the rollup.
    If you run this before rollup, the results will gone after rollup.
    This is not good.
    Check out using dynamic calc member formula may be the better option
    If(@ismbr(Actual))
    DimX_3;
    else
    DimX_1+DimX_3;
    endif

  • Essbase Calculation Script taking more time in new environment

    Hi Everyone:
    We have four environments in our implementation.
    1. DEV Environment - 64 bit Essbase Version 11.1.1.3
    2. PreProd Environment - 32 bit Essbase Version 9.3.0
    3. PreProd Environment - 64 bit Essbase Version 11.1.1.3
    In the above mentioned environment PreProd Environment - 64 bit Essbase Version 11.1.1.3 is a newly installed
    environment.
    We have migrated our Application from PreProd Environment - 32 bit Essbase Version 9.3.0 to PreProd Environment - 64 bit Essbase Version 11.1.1.3. A calculation script that takes only 20 minutes in 32 bit PreProd is taking more than
    5 and half hours in newly installed 64 bit PreProd.
    We have also migrated our Application from DEV Environment - 64 bit Essbase Version 11.1.1.3 to PreProd Environment - 64 bit Essbase Version 11.1.1.3. The calculation script that takes only 20 minutes in 64 bit Dev is taking more than 5 and half hours in newly installed 64 bit PreProd.
    All the server settings and cache setting everything looks similar in all the three environments.
    Please advice us what are all the possibilities that creates the issue.
    Thanks and Regards,
    Prabhakar.

    Hi Cameron,
    Thanks for your reply.
    I have cross checked the Virtual memory in both servers,in new server it was declared high.
    Please find the cfg setting which we are using in our application.
    AGENTPORT 1423
    SERVERPORTBEGIN 32768
    SERVERPORTEND 33768
    AGENTDESC hypservice_1
    ;CSSREFRESHLEVEL auto
    ;SHAREDSERVICESREFRESHINTERVAL 30
    CALCCACHEHIGH 199999999
    CALCCACHEDEFAULT 150000000
    CALCCACHELOW     10000000
    CALCLOCKBLOCKDEFAULT 3000
    DATAERRORLIMIT 10000
    UPDATECALC FALSE
    EXCEPTIONLOGOVERWRITE FALSE
    CALCREUSEDYNCALCBLOCKS FALSE
    PORTUSAGELOGINTERVAL 15
    QRYGOVEXECTIME 600
    LOGMESSAGELEVEL INFO
    CALCPARALLEL 6
    MAXLOGINS 100000
    AGENTDELAY 100
    AGENTTHREADS 30
    AGTSVRCONNECTIONS 10
    SERVERTHREADS 25
    EXPORTTHREADS 1
    SSLOGUNKNOWN FALSE
    CALCNOTICEDEFAULT 10
    NETRETRYCOUNT 3000
    NETDELAY 2000
    __SM__BUFFERED_IO TRUE
    __SM__WAITED_IO TRUE
    and aslo find the caches that we define:
    Index cache:250000
    Data Cache:250000
    Data file cache:32768
    The all above settings are identical both servers.
    In New server ,only one script that is taking more time but remaining scripts are working fine with less time.
    We also did one test cause that splitting the script in to multiple and executed ,in this cause the script where we are using direct assigning value from member(say A1) to another member(Say A2) is taking more time.But same scripts we executed in old server it executes fine.
    Still we are not able to find out exact root cause for this issue.
    Could please anyone help me to resove this issue.
    Regards,
    Prabhakar.

  • Data calculations in Indesign CS5

    I am wondering if there is a way to have indesign do date calculations. For instance, I enter a departure date for a trip into the document. The fine print in the document needs to have multiple dates filled in that are all a certain number of days before the departure day. 150 days before, 100, and 60. Is there a way to automate this?

    Javascript for InDesign has a Date object: http://jongware.mit.edu/idcs5js/pc_Date.html
    I guess you could use that to do the calculations. You could, for example, have a script that allows you to enter a date and then shows the list of prior-to dates, allowing you to copy them nto your document.
    Of course there is much more possible as well.

  • Error in Calculation Script TCP IP Error

    <p>Hi all,</p><p> </p><p>I am getting a strange error while running a calculation scriptthrough esscmd.</p><p> </p><p>When i run a calculation script from ESSCMD i get"Network Error: The client or server timed out waiting toreceive data using TCP/IP. Check network connections. Increase theNetRetryCOunt and/or NetDelay values in the ESSBASE.CFG file.Update tis file on both client and server. Restart the client andtry again"<br><br>Actually the script was running fine last week but since 3 daysit's throwing an error.<br><br>The scripts are running from ESSCMD and there are 5 calc scriptsruns. First and Second goes through fine and execute with sts id =0. Starting 3rd calc script it is throwing this error.<br><br>All calc scripts starts with<br>//ESS_LOCALE English_UnitedStates.Latin1@Binary<br>SET CACHE HIGH;<br>SET MSG SUMMARY;<br>SET NOTICE DEFAULT;<br>SET UPDATECALC OFF;<br>SET CALCPARALLEL 7;<br>SET CREATEBLOCKONEQ ON;<br><br>1. Calc Script 1 is about 1988 lines. - Executed successfully<br>2. Calc Script 2 is about 1988 lines. - Executed successfully<br>3. Calc Script 3 is about 600 lines - Throwing TCP/ IP Error<br>4. Calc Script 4 is about 600 lines - Throwing TCP/ IP Error<br>5. Aggregation script - Throwing TCP / IP Error.</p><p> </p><p>Any idea... ??</p><p> </p><p>Thanks in advance..    <br><br><br></p>

    While there is a possibility that you are seeing a real network error, you might want to run a couple of checks if you are running the script that runs the calc on a different unit than the server. If it is the network, changes to the NETDELAY and NETRETRYCOUNT will help.<BR><BR>But more likely, it is a problem with the essbase server and the specific app process. I'd suspect that the calc and other things happening are swamping the memory and/or overloading IO.<BR><BR>Take good look at your cube, it's block sizes, and the nature of the calcs you are running. How many blocks are needed to do a particular calc, and will those all fit in memory at the same time?<BR><BR>You may need to modify your SET MSG and SET NOTICE parameters so that you can identify the specific step where your calc is having problems. Those are long calc scripts, you may find it useful to break them into smaller modules for testing to determine what the problem is. Also, you need to look at the server and app logs to see if there are any hints there.<BR><BR>The "Network Error" message is quite non-specific; it only says that the communication has failed, not why. In my experience, it more often happens when a an app or the main server process freezes up, and it may actually take a shutdown and restart of at least Essbase if not the whole server.<BR><BR>As an additional note: Is the database fragmented? All apps benefit from a periodic export, reset, reload routine to defrag the database.

  • Sql date calculation

    I need a date calculation that will start with a date, 20061007, and add 7 days to it. Each week I will be running a unix script, executing the sql, to recalculate the date. I have tried various forms of the following, but have not had any luck:
    SELECT TO_DATE((20061015, 'yyyymmdd') - 7) FROM dual
    Cany anyone help? Thank you.

    SQL> SELECT TO_DATE('20061015', 'YYYYMMDD') + 7 FROM dual;
    TO_DATE('20
    22-OCT-2006

  • Advice on calculation script

    I have a BSO cube with 9 dimensions ( 3 dense + 6 sparse ). One of the sparse dimensions is a date with a hierarchy structure of year/year&qrt/year&month/year&month&day. At midnight for every day I'm running a load rule that loads the previous days data into the cube.
    If I perform a full calc of the cube, it takes approx 30mins, if I use a script to only recalculate the newly added date, it takes approx 60mins. Script as follows:
    //ESS_LOCALE English_UnitedStates.Latin1@Binary
    SET UPDATECALC OFF;
    SET CALCPARALLEL 4;
    FIX(@ALLANCESTORS("01/08/2011"))
         CALC DIM(dense_dim_1,dense_dim_2,dense_dim_3,sparse_dim_1,sparse_dim_2,sparse_dim_3,sparse_dim_4,sparse_dim_5);
    ENDFIX
    @ALLANCESTORS("01/08/2011");
    SET UPDATECALC ON;
    This would be the script run on the 2nd Aug to calculate the values for the 1st.
    Can anyone advise on how I can speed up the single day calculation? or revise the calculation script to be more efficient. The Outline dimensions follow the normal hourglass on dimension members.
    Thanks

    I see a couple of things that could be possible.
    1. Try to only calculate the level 0 intersections, then use the AGG on sparse dimensions.
    2. Do you really need to do CALC DIM on your dense dimensions? I like to build my dense dimensions using upper level dynamic calc, that way you don't need to do a CalcDim.
    3. Have a read of "Optimizing Calculations" in the DBAG http://download.oracle.com/docs/cd/E12825_01/epm.111/esb_dbag/frameset.htm?dcaoptcs.htm
    Robert

  • Question about calculation script 'Fix'

    Hi Guys,
    I have a question about calculation script 'Fix'. Below is the sample for my question:
    Dimension 'Period' has members '2009','2010','2011'. We want to Fix the data which 'Period' is not '2009'.
    From Database Administrator's Guide we could use @NOTEQUAL, but version 11.1.1.3.0 seems not support @NOTEQUAL.
    Actually, the dimension is dynamic so we cannot use the way fixing other memebers. What should I do for this requirement?
    Edited by: 842270 on Apr 24, 2011 7:29 PM

    842270 wrote:
    Hi Guys,
    I have a question about calculation script 'Fix'. Below is the sample for my question:
    Dimension 'Period' has members '2009','2010','2011'. We want to Fix the data which 'Period' is not '2009'.
    From Database Administrator's Guide we could use @NOTEQUAL, but version 11.1.1.3.0 seems not support @NOTEQUAL.
    Actually, the dimension is dynamic so we cannot use the way fixing other memebers. What should I do for this requirement?
    Edited by: 842270 on Apr 24, 2011 7:29 PMYou can use @Remove command to avoid 2009.
    @REMOVE
    Removes values or members in one list from another list.
    Syntax
    +@REMOVE (list1, list2)+
    Parameter     Description
    list1
    +     A list of member specifications, from which the members specified in list2 are removed.+
    list2
    A list of member specifications to be removed from list1.

Maybe you are looking for