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
------------------------------
Original Message:
Sent: Thu September 19, 2019 01:40 PM
From: George Tonkin
Subject: How does one share a variable definitions across Metadata and Data sections?
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
------------------------------