Using EXPAND function for dynamic code

Post Reply
fleaster
Regular Participant
Posts: 167
Joined: Wed Mar 30, 2011 11:57 pm
OLAP Product: TM1
Version: 10.2.2
Excel Version: XL2010

Using EXPAND function for dynamic code

Post by fleaster »

Ok, so I know you can use EXPAND to extract variables dynamically... e.g. :

Code: Select all

Ref = 'V1' ;
Customer = EXPAND( '%' | Ref | '%' );
...this works, but if I want to add an additional piece of code to the mix:

Code: Select all

Ref = 'Trim(V1)' ;
Customer = EXPAND( '%' | Ref | '%' );
...it errors out with : Variable "Trim(V1)" not found

So what I'd like to know is if there is a way/syntax to leverage the EXPAND function to pass more complex code for variables in a TI process?

Note: this is in the context where you may have different file layouts, and different treatment for each field e.g. you may want to Trim Field1, take the 1st 3 characters of Field2, do an IF function on Field3 etc etc - so wanted to see if there is a way this could be parameterized via lookup cube containing the code strings

Thanks!

Matt
BrianL
MVP
Posts: 264
Joined: Mon Nov 03, 2014 8:23 pm
OLAP Product: TM1
Version: 9.5.2 10.1 10.2 PA2
Excel Version: 2016

Re: Using EXPAND function for dynamic code

Post by BrianL »

Sorry, EXPAND will only replace variable names with their contents. It cannot be used to run arbitrary TI code.
fleaster
Regular Participant
Posts: 167
Joined: Wed Mar 30, 2011 11:57 pm
OLAP Product: TM1
Version: 10.2.2
Excel Version: XL2010

Re: Using EXPAND function for dynamic code

Post by fleaster »

dang... ok there goes my plans for world domination :(
lotsaram
MVP
Posts: 3702
Joined: Fri Mar 13, 2009 11:14 am
OLAP Product: TableManager1
Version: PA 2.0.x
Excel Version: Office 365
Location: Switzerland

Re: Using EXPAND function for dynamic code

Post by lotsaram »

Not clear what you want to do but you can nest Expand functions, e.g. inner expand derives variable name from concatenation of root string and integer counter, outer expand returns the value of the returned variable name from the inner.
Please place all requests for help in a public thread. I will not answer PMs requesting assistance.
fleaster
Regular Participant
Posts: 167
Joined: Wed Mar 30, 2011 11:57 pm
OLAP Product: TM1
Version: 10.2.2
Excel Version: XL2010

Re: Using EXPAND function for dynamic code

Post by fleaster »

So this is in the case if you wanted to retrieve a range of variables like "V1", "V2", "V3" etc...

...my issue is if you want to store more complex formula strings i.e. I have multiple import files which have the same field layouts, but depending on the source of the file, the treatment of the same field may be different

e.g. for Field #1, I may want to Trim it for one file, for another I want to assign "NA" if it's blank, for another I may want to add a fixed prefix etc:
"Trim(V1)" / "IF(V1@='','NA',V1)" / " 'abc123' | V1"

Now it's easy enough to add multiple IF functions, but these would be hardcoded - so am trying to see if the formula strings can be held in a parameter cube so that whenever a new file comes up, we can just update the parameters instead of amending the code.
lotsaram
MVP
Posts: 3702
Joined: Fri Mar 13, 2009 11:14 am
OLAP Product: TableManager1
Version: PA 2.0.x
Excel Version: Office 365
Location: Switzerland

Re: Using EXPAND function for dynamic code

Post by lotsaram »

Expand just allows for getting the value of a variable from a string of the variable name. You can't "expand" strings into functional code though as the function is limited to variables only.

Your idea is interesting though. Provided that the set of possible conditions and treatments per field was known in advance then it would be possible to build a process with the kind of logic you are talking about, just by testing values and if statements no need for expand. Of course it wouldn't be infinitely flexible like what you are really talking about but maybe it's an option.
Please place all requests for help in a public thread. I will not answer PMs requesting assistance.
RJ!
Community Contributor
Posts: 219
Joined: Mon Jul 23, 2012 8:31 am
OLAP Product: TM1
Version: 10.2.2
Excel Version: 2010

Re: Using EXPAND function for dynamic code

Post by RJ! »

Would the JAVA extensions help in this case?

i.e. solve the "expand" in JAVA and bring it back to TI?
Post Reply