Updating dimension elements using TI with multiple level hierarchy

Post Reply
manpreet
Posts: 25
Joined: Mon May 20, 2019 9:54 am
OLAP Product: TM1
Version: 10.2.2
Excel Version: 2013

Updating dimension elements using TI with multiple level hierarchy

Post by manpreet »

Hiii team,

I have a urgent requirement for this.

I have flat file in which there are 10-15 columns
To update the dimension
1column = N level elements.
And remaining are 12 columns in which the parent info is given.
Fir example consider the heading of other columns from group 1 to group 2.
A hierarchy is to be made in the dimension
Lowest level will be child element > group1> group 2 and so on till group 12.
I have already made the ti and it's working perfect when I am taking only 2 groups

So there are conditions that
1. Duplicate names in Group 1 or Group3 or any other
2. Blanks in the groups but have data in further groups

I have to fill these condition and to apply the code for according to the condition.

Thanks
declanr
MVP
Posts: 1815
Joined: Mon Dec 05, 2011 11:51 am
OLAP Product: Cognos TM1
Version: PA2.0 and most of the old ones
Excel Version: All of em
Location: Manchester, United Kingdom
Contact:

Re: Updating dimension elements using TI with multiple level hierarchy

Post by declanr »

Without more info I would suggest just appending a number to each "level" to make sure the element names are unique.

If your n-level column variable is called "node" and your other 12 columns for element names were col1 through to col12 then something like below on your metadata should theoretically work.

Code: Select all

sChild = Node;


iCount = 1;
iMax = 12;
While ( iCount <= iMax );
	sElement = Expand ( '%Col' | NumberToString ( iCount )| '%' );
	If ( sElement @<> '' );
		sParent = NumberToString ( iCount ) | ' - ' | sElement;
		DimensionElementInsert ( cDimName, '', sParent, 'C' );
		DimensionElementComponentAdd ( cDimName, sParent, sChild, 1 );
		sChild = sParent; 
	EndIf;
	iCount = iCount + 1;
End;
Edit - simplified by removing unneccessary step.
Declan Rodger
manpreet
Posts: 25
Joined: Mon May 20, 2019 9:54 am
OLAP Product: TM1
Version: 10.2.2
Excel Version: 2013

Re: Updating dimension elements using TI with multiple level hierarchy

Post by manpreet »

There are 12 columns group 1, group 2, ... group 12.which will make hierarchy.
Twist is I also have to write a 2 conditions that
If group 1 is equal to group 2 than only take group 2 skip the group 1.
And also one more condition that
If group 1 is blank then skip it and jump to group 2.

And this combination I have to write for all the groups till 12.
I don't want to write for every group.
I want to optimise it so what can be the solution.
I have never used while loop before
Declanr thanks for the code will surely try it and revert back
manpreet
Posts: 25
Joined: Mon May 20, 2019 9:54 am
OLAP Product: TM1
Version: 10.2.2
Excel Version: 2013

Re: Updating dimension elements using TI with multiple level hierarchy

Post by manpreet »

Hi Declanr

I want to take unique elements only if it's blank or repeated I want to skip it you are making all the 12 unique your code is perfect if someone wants to insert all the 12 hierarchies.

Thank you :)
Post Reply