Planning Analytics

Planning Analytics

Get AI-infused integrated business planning

 View Only
  • 1.  How does one share a variable definitions across Metadata and Data sections?

    Posted 09/19/19 12:01 PM
    I defined a local variable in the Prolog section.

    StringSessionVariable('V_Name');

    I assigned a value to the variable in the Metadata section, such that I can use it to create members for a dimension.

    V_Name = V_A | V_B; (Note that V_A and V_B come from a data file load)

    I next want to use the values of that variable in updating attributes for the members in the Data section.

    The variable values cannot be used as it is presumably out of scope.

    How can I (a) define the variable in the Prolog section? (b) Use that definition in the Metadata and then the Data section?

    Do I use the Expand function (as suggested in another post)? If so, could you please provide me an example? I tried it using the following link but it is raising an error in the Ti process editor.

    https://www.ibm.com/support/knowledgecenter/en/SSD29G_2.0.0/com.ibm.swg.ba.cognos.tm1_ref.2.0.0.doc/r_tm1_ref_tifun_expand.html



    V_Name = EXPAND("%V_Name%")

    ------------------------------
    Shubho Ghosal
    ------------------------------

    #PlanningAnalyticswithWatson


  • 2.  RE: How does one share a variable definitions across Metadata and Data sections?

    Posted 09/19/19 01:40 PM

    You need to think carefully about where variables are used and when you assign values.  If you are defining a constant, or setting a value which remains the same throughout the process then set in Prolog.

    If the variable needs to change based on a record you are processing, update in Metadata and/or Data.
    Your expand example would be recursive.  Generally you would use expand to evaluate the value denoted by the string between then percentage signs e.g. V_Value=EXPAND('%'|sMeasure|'%'); 

    If sMeasure had a value of V1 and your datasource variables had a Variable called V1, V_Value would contain the value in V1 for that record after being evaluated i.e. If V1 in the source file related to a column in a text file and contained colours, V_Value would return whichever colour was assigned to that record in the source.



    ------------------------------
    George Tonkin
    ------------------------------



  • 3.  RE: How does one share a variable definitions across Metadata and Data sections?

    Posted 09/20/19 11:22 AM
    Thanks for providing the syntax of the EXPAND function.

    I was hoping to use it to find a solution to the problem of having to copy the assignment of a variable (or its definition) across the Metadata and Data sections.

    The issue is that the variable assignment is a long concatenation of several data source variables, with separator strings in between. I.e., I am trying to use several variables to create a member name.

    Example: V_Name = V_Area | ' - ' | V_Age etc.

    I am using V_Name in the Metadata section to create the name of the members, which I then insert into the dimension concerned.

    I am also using V_Name in the Data section to identify the newly created members and using that information to update attribute values of the members using a series of ATTRS functions (one for each attribute).

    I am using the same data source variables as before, and this works.

    My assumption is that I cannot do both in the Metadata section, as the dimension attributes need to be created first. (Please correct me if I am wrong).

    The issue is that I am having to copy the variable assignment of V_Name in the Data section as well. I was hoping to be able to create the definition once and use it in both sections.

    Please let me know if there is a solution to this type of a problem. Whether or not I was correct in updating the attributes in the Data section (as opposed to the Metadata section), I would very much like to know if there is a way to define a variable once and use it in both the Metadata and Data sections, and how I would do that.

    ------------------------------
    Shubho Ghosal
    ------------------------------



  • 4.  RE: How does one share a variable definitions across Metadata and Data sections?

    Posted 09/24/19 02:59 PM
    Hi,

    You are doing it correctly.  Structural changes happen in the metadata tab, and data changes happen in the data tab.   TIs are processed a section at a time.  This means if you are using a variable that depends on source data, then the variable has changed with each row of metadata before it gets to the first row in the data tab.  So V_NAME does need to be defined in both Metadata and Data tabs.

    Good luck!

    PS - Technically it is possible to do the dimension changes in the data tab using the "direct" version of a function (dimensionElementInsertDirect).  However, I recommend that the direct functions be used for exception handling when doing data loads and you find an element missing, rather than when you are building a dimension.

    ------------------------------
    Scott Brown
    ------------------------------



  • 5.  RE: How does one share a variable definitions across Metadata and Data sections?

    Posted 09/25/19 01:43 PM
    Thanks, Scott, for confirming that I am doing the right thing by creating the members in the metadata section and updating their attributes in the data section.

    I suppose, at this point, one would need to recreate the same variable definition / assignment in both the metadata and data sections. This is not the biggest deal as you only need to do it once in each section, and can reuse the variable multiple times within either section, which is a huge advantage in itself.

    No further questions on this particular post - thanks to everyone for taking the time to respond!

    ------------------------------
    Shubho Ghosal
    ------------------------------