Page 1 of 1
TI process to copy values
Posted: Tue Jul 14, 2009 3:16 am
by Ross
Hi,
I've written a dynamic view using MDX. I would now like to copy the values in this view to another dimension element. One approach would be to import the view into another process and use Cellputn to transfer the value into the new element. But it would be good to be able to do this within the same process. I guess this would be done by looping through the values in the view but what is the best approach to retrieve these values and determine the size of the view to loop through? (does it involve looping through the SubsetGetSize value for each subset?)
Many thanks
Ross
Re: TI process to copy values
Posted: Tue Jul 14, 2009 1:49 pm
by wissew
Ross,
Here is some code we use to loop though subsets to load. You need to fill in the blanks.
Wes
DimName =' ';
vSubSet = 'N Elements';
vSubSize = subsetgetsize(DimName,vSubSet);
vSubsetCount = 1;
#***** Limits loop to subset size
While (vSubsetCount <= vSubSize);
#*****Retrieves element number 1 - n
vDimElement=SubsetGetElementName(DimName, vSubSet, vSubsetcount);
vLoadAmt=Cellgetn( )*Value;
#Loads the calculated amount from above!
CellPutN( );
#Continue Looping
vSubsetCount = vSubsetCount + 1;
end;
Re: TI process to copy values
Posted: Tue Jul 14, 2009 6:11 pm
by Wim Gielis
Hi
The usual approach is this:
- - create a view on your cube (manually). Lay out the dimensions in the view in the order of the dimensions in this cube (this makes your work easier in the TI process). Save the view.
- - start a new TI process, set the view you saved as the Data source. Your variables should be correct now. (see the Variables tab). You have 1 extra variable: it's called Value
Since a view is the data source, the TI process itself will create a loop through each of the non-zero values in the view.
- - In the Prolog tab, put your code to create the view. Create the view with the same name you used earlier. Do NOT do a ViewZeroOut.
- - In the Data tab, write the CELLPUTN(Value, 'CUBENAME', ELEMENT NAMES) statement. The element names are simply the names of the variables in the process. By default, these are the same as the dimension names.
- - In the Epilog tab, put your code to delete the the temporary view and the temporary subsets.
Most of the time, you will also need a View and a ViewZeroOut for the element to which you copy the data. (to avoid double countings). This code is rather easy once you have the code for the first view. Also, turn cubelogging off in the prolog and on in the epilog.
Wim