Forum Discussion

Jeevan's avatar
Jeevan
New Contributor II
9 months ago

setdatacell not working if the scenario setting "clear calculated data during calc" is set to TRUE

Hi Everyone,

I am trying to allocate forecast data to the gl's based on the last year actuals data. The allocation is not happening when the forecast scenario setting "clear calculated data during calc" is set to TRUE. If I set it as FALSE, the allocation is happening.

This data is copied using the setdatacell from the allocated value to the target script in which origin member is O#forms. 

It seems the value is not written to the origin member if I set the scenario setting to true.

can someone explain me what is happening? Also, I tried adding the below calculate and clear code. 

api.data.calculate($"{script} = 0 * {script}")

api.data.clearcalculateddata(script)

It worked until I did not change any data, once I changed the data, the allocation did not happen again.

 

 

Thanks,

Jeevan

 

  • JackLacava's avatar
    JackLacava
    Honored Contributor

    I don't really follow... Where exactly did you place your "allocation" code? Is it a Member Formula, a Custom Calculate...?

    "Clear calculated data during calc" will wipe from the Data Unit any record generated by previous runs of any rule, before any rule is executed again. That means any record pointing to the same Cube/Scenario/Period/Entity/Parent/Consolidation combination of members, which was not the result of an Import or Form operation, will be deleted as soon as you trigger a new Calculate/Translate/Consolidate that involves that Data Unit.

    I have a feeling your "source" records are the result of calculations, your code triggers a calculation that inevitably wipes them, and hence your code doesn't find any data to work with. If the entire Data Unit at that point is empty, the rule might not even run at all, depending on the "No Data" properties set on the Cube. If that is the case, you will have to make sure that the source data is marked as Durable.

    • Jeevan's avatar
      Jeevan
      New Contributor II

      Hi Jack,

      Thanks for the response and information. It is a custom calculate br. The issue was fixed for me after adding  isdurablecalculated data to true in the setdatacell.

       

      Thanks

       

       

      • sameburn's avatar
        sameburn
        Contributor II

        Ok this is expected behaviour then based on omitting the isDurableData boolean from your api.data.calculate formula.