Page 1 of 1

carry forward a dimension elements to another dimension

Posted: Wed Dec 06, 2017 1:21 am
by Analytics123
Hi,

I have a dimension say A having certain elements with unbalanced hierarchy.

Now I have a dimension b similar to A with unbalanced hierarchy. Now my requirement is to iterate all elements with in dimension B and add them below dimension A .

SO bascically i will have to take elements in dimnesion b and copy over along with dimension A elements daily.

How do I automate this process. Copy elements from Dimension B and add it to dimension A .

Re: carry forward a dimension elements to another dimension

Posted: Wed Dec 06, 2017 9:41 am
by ascheevel
Dimension A is an exact copy of Dimension B, why not use only one dimension? If you must use two dims, you can use a WHILE loop in the prolog or epilog tab of a TI process to spin through all elements in Dimension B and add to Dimension A. Below is sample code for looping through all elements of Dimension B and adding each to Dimension A. You would need additional code if you want to copy the parent/child relationships to Dimension A. You've a couple options for doing that, one would be to evaluate all parents of the element being evaluated, make sure the parent exists in Dimension A, and then add the parent/child relationship. I bet there's other posts in the forum explaining how to that as well as other options for copying parent/child relationships from one dim to another.

Code: Select all

# not debugged, so errors likely present
vDim1 = 'Dimension B';
vDim2 = 'Dimension A';
vLimit = DIMSIZ(vDim1);
index1 = 1;

WHILE(index1 <= vLimit);
	vElement = DIMNM(vDim1, index1);
	vType = DTYPE(vDim1, vElement);
	DimensionElementInsert(vDim2, '', vElement, vType);
	index1 = index1 + 1;
END;

Re: carry forward a dimension elements to another dimension

Posted: Wed Dec 06, 2017 1:40 pm
by Analytics123
Its not an exact copy , its like appending dimension B to dimension A. DImension B might change some times , so the append process to unwind dimension b elements added to dimension A and readd them daily .

Re: carry forward a dimension elements to another dimension

Posted: Wed Dec 06, 2017 2:18 pm
by Elessar
If you understand you right, bedrock.dim.clone with pUnwind=2 will solve your task:
https://github.com/cubewise-code/bedroc ... .Clone.pro

Re: carry forward a dimension elements to another dimension

Posted: Mon Dec 11, 2017 1:58 am
by Analytics123
hi,

I am adding to dimension A , but I am just appending dimension b to dimension A. But dimension B can change any time and that needs to be reflected on DImension A on daily basis.

So I have to unwind Dim B elements in Dim A daily and then readd dim B elements to dim A .

so to append Dim B to Dim A.

I need a ti that will loop through all the elements of dim b and append it to dim A .

But how do i maintain/bring in the parent child relationship of dim B while appending.

Thanks,

Re: carry forward a dimension elements to another dimension

Posted: Mon Dec 11, 2017 7:06 pm
by Wim Gielis
Analytics123 wrote: Mon Dec 11, 2017 1:58 am hi,

I am adding to dimension A , but I am just appending dimension b to dimension A. But dimension B can change any time and that needs to be reflected on DImension A on daily basis.

So I have to unwind Dim B elements in Dim A daily and then readd dim B elements to dim A .

so to append Dim B to Dim A.

I need a ti that will loop through all the elements of dim b and append it to dim A .

But how do i maintain/bring in the parent child relationship of dim B while appending.

Thanks,
Using the functions ElparN and Elpar you can loop over all parents of an element.
That way, you can DimensionElementComponentAdd an element to its parent(s) in the other dimension.