SubsetElementInsert difference between Position Index=1 and =2 in behaviour

Post Reply
pikolikoli
Posts: 38
Joined: Sun May 17, 2020 2:37 am
OLAP Product: tm1
Version: 10.2
Excel Version: 2013

SubsetElementInsert difference between Position Index=1 and =2 in behaviour

Post by pikolikoli »

Hello Everyone,

I was just testing some code and found a SubsetElementInsert like this :
SubsetDestroy(zDim , zView );
SubsetCreate(zDim, zView );
SubsetElementInsert ( zDim , zView ,'Elem 1', 1 );
SubsetElementInsert ( zDim , zView ,'Elem 2', 1 );
SubsetElementInsert ( zDim , zView ,'Elem 3', 1 );
I found That 1 is the position where we want to insert an element in subset. So what is the difference in behaviour between if I put my subset like this :
SubsetDestroy(zDim , zView );
SubsetCreate(zDim, zView );
SubsetElementInsert ( zDim , zView ,'Elem 1', 1 );
SubsetElementInsert ( zDim , zView ,'Elem 2', 2 );
SubsetElementInsert ( zDim , zView ,'Elem 3', 3 );
Why Are we inserting all the elements on the same position ? woudnt inserting all the elements in the same position erase the last inserted value so we will end up with only Elemnt3 ? and what will happend if we insert them in different position ? When should we use the first case and when should we use the second case ?

Thank you
tomok
MVP
Posts: 2832
Joined: Tue Feb 16, 2010 2:39 pm
OLAP Product: TM1, Palo
Version: Beginning of time thru 10.2
Excel Version: 2003-2007-2010-2013
Location: Atlanta, GA
Contact:

Re: SubsetElementInsert difference between Position Index=1 and =2 in behaviour

Post by tomok »

Putting 1 as the index means insert it into the first position in the subset. All the other members will be moved down a spot.
Tom O'Kelley - Manager Finance Systems
American Tower
http://www.onlinecourtreservations.com/
pikolikoli
Posts: 38
Joined: Sun May 17, 2020 2:37 am
OLAP Product: tm1
Version: 10.2
Excel Version: 2013

Re: SubsetElementInsert difference between Position Index=1 and =2 in behaviour

Post by pikolikoli »

tomok wrote: Wed Dec 23, 2020 2:57 pm Putting 1 as the index means insert it into the first position in the subset. All the other members will be moved down a spot.
Thank you very much I understand Now.
Wim Gielis
MVP
Posts: 3121
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1, Jedox
Version: PAL 2.0.9.18
Excel Version: Microsoft 365
Location: Brussels, Belgium
Contact:

Re: SubsetElementInsert difference between Position Index=1 and =2 in behaviour

Post by Wim Gielis »

Use 0 everywhere if you want to insert elements in the order in which they are listed in the code.
Best regards,

Wim Gielis

IBM Champion 2024
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
Post Reply