add part of dimension to a new dimension

Post Reply
Analytics123
Posts: 128
Joined: Tue May 23, 2017 12:45 pm
OLAP Product: Tm1
Version: 9.5
Excel Version: 2010

add part of dimension to a new dimension

Post by Analytics123 »

Hi,

I have a dimension say car which has elements with parent ,child relation with different levels.

car-> Toyota->SE,LE,XE
Hundai->Model1->XSE

now I need to copy all these elements to another dimension say 4 wheelers with a parent child relation in car

I will create a subset of all N level in car dimension and iterate all the elements.

but how i do add them with their parent child relation , so in above case, I get values like XSE,SE,LE and XE in N how do I construct my car dimension again .

should i use ELPARN for each element and add its parent?should this be in a while loop.

ELPARN (XSE) will give 2 .

Thanks,
Edward Stuart
Community Contributor
Posts: 247
Joined: Tue Nov 01, 2011 10:31 am
OLAP Product: TM1
Version: All
Excel Version: All
Location: Manchester
Contact:

Re: add part of dimension to a new dimension

Post by Edward Stuart »

Do the values derive from a source file? What are the other parent child relationships in the dimension?
tm123
Posts: 132
Joined: Thu Oct 23, 2014 10:15 pm
OLAP Product: tm1, cognos bi
Version: 10.2
Excel Version: 2010

Re: add part of dimension to a new dimension

Post by tm123 »

Analytics123 wrote: Thu Jan 18, 2018 1:58 am Hi,

I have a dimension say car which has elements with parent ,child relation with different levels.

car-> Toyota->SE,LE,XE
Hundai->Model1->XSE

now I need to copy all these elements to another dimension say 4 wheelers with a parent child relation in car

I will create a subset of all N level in car dimension and iterate all the elements.

but how i do add them with their parent child relation , so in above case, I get values like XSE,SE,LE and XE in N how do I construct my car dimension again .

should i use ELPARN for each element and add its parent?should this be in a while loop.

ELPARN (XSE) will give 2 .

Thanks,
ELPARN will return the number of Parents of the specified element. It looks like you have Multiple Hierarchies in your dimension, that's why your ELPARN (XSE) returns value of 2. If you don't have multiple hierarchies, then the other possibility is you are double consolidating your N elements which would give you wrong results

So if you want all parents to be inserted in you Target dimension, then you will have to loop:

nParentsCount = ELPAR ( sSourceDimName , sLeafElement ) ;
nParentIndex = 1 ;
WHILE ( nParentIndex <= nParentsCount ) ;
sParentElement = ELPAR ( sSourceDimName , sLeafElement , nParentIndex ) ;
nWeight = ELWEIGHT ( sSourceDimName , sParentElement , sLeafElement ) ;
DIMENSIONELEMENTINSERT ( sTargetDimName , '' , sParentElement ,'C' ) ;
DIMENSIONELEMENTCOMPONENTADD ( sTargetDimName , sParentElement , sLeafElement , nWeight ) ;
nParentIndex = nParentIndex + 1 ;
END ;
User avatar
Steve Rowe
Site Admin
Posts: 2410
Joined: Wed May 14, 2008 4:25 pm
OLAP Product: TM1
Version: TM1 v6,v7,v8,v9,v10,v11+PAW
Excel Version: Nearly all of them

Re: add part of dimension to a new dimension

Post by Steve Rowe »

If this is a one off then if you select the structure sorted by hierarchy in the source subset, hit Ctrl+C and then Ctrl+V in the dimension editor for the destination then it works pretty well.
Technical Director
www.infocat.co.uk
Analytics123
Posts: 128
Joined: Tue May 23, 2017 12:45 pm
OLAP Product: Tm1
Version: 9.5
Excel Version: 2010

Re: add part of dimension to a new dimension

Post by Analytics123 »

this code doesn't work if I have more than 1 child .

Example

Car-> camry->level1 ->s4

iterate all n level , we get s4 ,

now only s4 and its parent level 1 is copied to the new dimension . I still wanted camry and car .
tm123
Posts: 132
Joined: Thu Oct 23, 2014 10:15 pm
OLAP Product: tm1, cognos bi
Version: 10.2
Excel Version: 2010

Re: add part of dimension to a new dimension

Post by tm123 »

The code i wrote earlier will insert only the Direct Parent of the Elements in the subset. But you can modify the code to insert all parents from source dim. Just add an extra loop to find the other parents

You still can use the ELPAR function
Post Reply