Page 1 of 1

add part of dimension to a new dimension

Posted: Thu Jan 18, 2018 1:58 am
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,

Re: add part of dimension to a new dimension

Posted: Thu Jan 18, 2018 7:52 am
by Edward Stuart
Do the values derive from a source file? What are the other parent child relationships in the dimension?

Re: add part of dimension to a new dimension

Posted: Thu Jan 18, 2018 12:34 pm
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 ;

Re: add part of dimension to a new dimension

Posted: Thu Jan 18, 2018 12:38 pm
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.

Re: add part of dimension to a new dimension

Posted: Thu Jan 18, 2018 8:59 pm
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 .

Re: add part of dimension to a new dimension

Posted: Mon Jan 22, 2018 12:00 pm
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