Transfer Data from 1 element to another and erasing data

Post Reply
appleglaze28
Regular Participant
Posts: 269
Joined: Tue Apr 21, 2009 3:43 am
OLAP Product: Cognos TM1, Planning
Version: 9.1 SP3 9.4 MR1 FP1 9.5
Excel Version: 2003

Transfer Data from 1 element to another and erasing data

Post by appleglaze28 »

I was wondering, what's the best way to transfer data 1 element to another with the same cube and zero out that original element's data without deleting the element in the dimension.

I do have to define a cube view of the cube and just edit the dimension that's gonna be doing the transfering, right? IF so im getting an invalid expression with the code below. I have 3 more cubes that needs to do these. This is my first time to use the VALUE_IS_STRING...so I'm not too familiar yet on how it works.

Code: Select all

if (VALUE_IS_STRING=1, CellGetS(SVALUE,'general_so_setting',base_worksheet_account_manager,base_worksheet_so_number,value_so_setting), CellGetN(NVALUE
, 'general_so_setting', base_worksheet_account_manager,base_worksheet_so_number,value_so_setting));
if (VALUE_IS_STRING=1, CellPutS(SVALUE,'general_so_setting',base_worksheet_account_manager,base_worksheet_so_number,value_so_setting), CellPutN(NVALUE
, 'general_so_setting', base_worksheet_account_manager,base_worksheet_so_number,value_so_setting));
kpk
MVP
Posts: 214
Joined: Tue Nov 11, 2008 11:57 pm
OLAP Product: TM1, CX
Version: TM1 7x 8x 9x 10x CX 9.5 10.1
Excel Version: XP 2003 2007 2010
Location: Hungary

Re: Transfer Data from 1 element to another and erasing data

Post by kpk »

Hello,

You use incorrect syntax in your Cellget functions.
CellGetS(SVALUE,'general_so_setting'
CellGetN(NVALUE,'general_so_setting'

The first argument in these functions has to be the name of the cube.
CellGetS('general_so_setting'
CellGetN('general_so_setting'

BTW:
You can see a useful sample code for coping data at the following link: http://www.wimgielis.be/
Check the "Copy all data from one element to another" article.

Regards,
Peter
Best Regards,
Peter
appleglaze28
Regular Participant
Posts: 269
Joined: Tue Apr 21, 2009 3:43 am
OLAP Product: Cognos TM1, Planning
Version: 9.1 SP3 9.4 MR1 FP1 9.5
Excel Version: 2003

Re: Transfer Data from 1 element to another and erasing data

Post by appleglaze28 »

How do I erase the element from the original source? Cause I'm not sure how that's done, I'm just familiar with zeroing out the whole view.
Alan Kirk
Site Admin
Posts: 6647
Joined: Sun May 11, 2008 2:30 am
OLAP Product: TM1
Version: PA2.0.9.18 Classic NO PAW!
Excel Version: 2013 and Office 365
Location: Sydney, Australia
Contact:

Re: Transfer Data from 1 element to another and erasing data

Post by Alan Kirk »

appleglaze28 wrote:How do I erase the element from the original source? Cause I'm not sure how that's done, I'm just familiar with zeroing out the whole view.
Your original post said that you didn't want to delete the element.
appleglaze28 wrote:and zero out that original element's data without deleting the element in the dimension.
Have you looked at the TM1 Reference Guide from the Help menu? It contains all of the TI commands, grouped by function. The relevant one in this case is DimensionElementDelete.

If you actually meant "erase the data relating to that element", you simply build a view with that one element (or as many as you want to erase) as one of the subsets which define the view (plus whatever other subsets are needed), and zero out that view.
"To them, equipment failure is terrifying. To me, it’s 'Tuesday.' "
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.
appleglaze28
Regular Participant
Posts: 269
Joined: Tue Apr 21, 2009 3:43 am
OLAP Product: Cognos TM1, Planning
Version: 9.1 SP3 9.4 MR1 FP1 9.5
Excel Version: 2003

Re: Transfer Data from 1 element to another and erasing data

Post by appleglaze28 »

Thanks for correcting me Alan, yeah I meant erasing the data from the orignal element.
Alan Kirk
Site Admin
Posts: 6647
Joined: Sun May 11, 2008 2:30 am
OLAP Product: TM1
Version: PA2.0.9.18 Classic NO PAW!
Excel Version: 2013 and Office 365
Location: Sydney, Australia
Contact:

Re: Transfer Data from 1 element to another and erasing data

Post by Alan Kirk »

appleglaze28 wrote:Thanks for correcting me Alan, yeah I meant erasing the data from the orignal element.
OK, well, that's the way you do it then; whether it's 1 element or 10,000, you just create a view and zero that view out.
"To them, equipment failure is terrifying. To me, it’s 'Tuesday.' "
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.
lotsaram
MVP
Posts: 3703
Joined: Fri Mar 13, 2009 11:14 am
OLAP Product: TableManager1
Version: PA 2.0.x
Excel Version: Office 365
Location: Switzerland

Re: Transfer Data from 1 element to another and erasing data

Post by lotsaram »

Or if it's actually a specific cell as it looks like it might be from the original post then simply CellPutN a 0 or CellPutS a space character.
appleglaze28
Regular Participant
Posts: 269
Joined: Tue Apr 21, 2009 3:43 am
OLAP Product: Cognos TM1, Planning
Version: 9.1 SP3 9.4 MR1 FP1 9.5
Excel Version: 2003

Re: Transfer Data from 1 element to another and erasing data

Post by appleglaze28 »

Thanks guys for the help...I was wondering if i would do this for 1 elements for 2 dimension, I would just probably need to copy the TI for the single element and adjust it base on the new dimension and its related element, right? So I did that....but the process runs okay but its like nothing happens to the cube. I was like thinkng of creating multiple TI to transfer them from 1 dimension to another but I would end up with 8 TI for just this task. Since I have 4 cubes I already have 4 TI for the transfer of 1 element in 1 dimension.

Maybe someone can help me look at the process and see why its running fine but nothing happens for the output...cause for example i inputted data for an element for a specific date, and it ends up being on the wrong element for the wrong date, that would be the purpose of transfering the data to elements in 2 dimensions.

Thanks Wim for the help on this.

PRAMETER:
pSourceElement
pTargetElement
pSourceElementDate
pTargetElementDate


PROLOG:

Code: Select all

## A. Explicit constants

vCubeName='worksheet';
vSourceViewName='Source';
vTargetViewName='Target';
vSourceSubsetName='Target';
vTargetSubsetName='Source';
pDimensionName='base_worksheet_so_number';
pDimensionDate='base_worksheet_date';




## B. Preliminary checks

#dimension-related
IF(DIMENSIONEXISTS(pDimensionName)=0);
     PROCESSQUIT;
ENDIF;

IF(DIMENSIONEXISTS(pDimensionDate)=0);
     ITEMSKIP;
ENDIF;

# elements-related
IF(DIMIX(pDimensionName,pSourceElement)=0);
     PROCESSQUIT;
ENDIF;

IF(DIMIX(pDimensionDate,pSourceElementDate)=0);
     PROCESSQUIT;
ENDIF;

IF(DIMIX(pDimensionName,pTargetElement)=0 %
   DTYPE(pDimensionName,pTargetElement)@='C');
     PROCESSQUIT;
ENDIF;

IF(DIMIX(pDimensionDate,pTargetElementDate)=0 %
   DTYPE(pDimensionDate,pTargetElementDate)@='C');
     PROCESSQUIT;
ENDIF;

IF(TRIM(pSourceElement)@=TRIM(pTargetElement));
     PROCESSQUIT;
ENDIF;

IF(TRIM(pSourceElementDate)@=TRIM(pTargetElementDate));
     PROCESSQUIT;
ENDIF;



# process-related
IF(DATASOURCETYPE@<>'VIEW');
     PROCESSQUIT;
ENDIF;

IF(DATASOURCENAMEFORSERVER@<>vCubeName);
     PROCESSQUIT;
ENDIF;

IF(DATASOURCECUBEVIEW@<>vSourceViewName);
     PROCESSQUIT;
ENDIF;


## C. Create a view containing all data for the Source element

# 1. Tidy up the Source view
VIEWDESTROY(vCubeName,vSourceViewName);
SUBSETDESTROY(pDimensionName,vSourceSubsetName);
SUBSETDESTROY(pDimensionDate,vSourceSubsetName);


# 2. Create subset
SUBSETCREATE(pDimensionName,vSourceSubsetName);
SUBSETELEMENTINSERT(pDimensionName,vSourceSubsetName,
                    pSourceElement,1);

SUBSETCREATE(pDimensionDate,vSourceSubsetName);
SUBSETELEMENTINSERT(pDimensionDate,vSourceSubsetName,
                    pSourceElementDate,1);



# 3. Create view & assign subset
VIEWCREATE(vCubeName,vSourceViewName);
VIEWSUBSETASSIGN(vCubeName,vSourceViewName,
                 pDimensionName,vSourceSubsetName);
VIEWSUBSETASSIGN(vCubeName,vSourceViewName,
                 pDimensionDate,vSourceSubsetName);

IF(DTYPE(pDimensionName,pSourceElement)@='C');
     VIEWSETSKIPCALCS(vCubeName,vSourceViewName,0);
ENDIF;

IF(DTYPE(pDimensionDate,pSourceElementDate)@='C');
     VIEWSETSKIPCALCS(vCubeName,vSourceViewName,0);
ENDIF;

VIEWSETSKIPRULEVALUES(vCubeName,vSourceViewName,0);




## D. Zero out a view containing all data for the Target element

# 1. Tidy up
VIEWDESTROY(vCubeName,vTargetViewName);
SUBSETDESTROY(pDimensionName,vTargetSubsetName);

VIEWDESTROY(vCubeName,vTargetViewName);
SUBSETDESTROY(pDimensionDate,vTargetSubsetName);


# 2. Create subset
SUBSETCREATE(pDimensionName,vTargetSubsetName);
SUBSETELEMENTINSERT(pDimensionName,vTargetSubsetName,
                    pTargetElement,1);
SUBSETCREATE(pDimensionDate,vTargetSubsetName);
SUBSETELEMENTINSERT(pDimensionDate,vTargetSubsetName,
                    pTargetElementDate,1);


# 3. Create view & assign subset
VIEWCREATE(vCubeName,vTargetViewName);
VIEWSUBSETASSIGN(vCubeName,vTargetViewName,
                 pDimensionName,vTargetSubsetName);
VIEWSUBSETASSIGN(vCubeName,vTargetViewName,
                 pDimensionDate,vTargetSubsetName);


# 4. Zero out the view
VIEWZEROOUT(vCubeName,vTargetViewName);


# 5. Tidy up
VIEWDESTROY(vCubeName,vTargetViewName);
SUBSETDESTROY(pDimensionName,vTargetSubsetName);
SUBSETDESTROY(pDimensionDate,vTargetSubsetName);

DATA:

Code: Select all

## A. Explicit constants

vCubeName='worksheet';
vSourceViewName='Source';
vTargetViewName='Target';
vSourceSubsetName='Target';
vTargetSubsetName='Source';
pDimensionName='base_worksheet_so_number';
pDimensionDate='base_worksheet_date';




## B. Preliminary checks

#dimension-related
IF(DIMENSIONEXISTS(pDimensionName)=0);
     PROCESSQUIT;
ENDIF;

IF(DIMENSIONEXISTS(pDimensionDate)=0);
     ITEMSKIP;
ENDIF;

# elements-related
IF(DIMIX(pDimensionName,pSourceElement)=0);
     PROCESSQUIT;
ENDIF;

IF(DIMIX(pDimensionDate,pSourceElementDate)=0);
     PROCESSQUIT;
ENDIF;

IF(DIMIX(pDimensionName,pTargetElement)=0 %
   DTYPE(pDimensionName,pTargetElement)@='C');
     PROCESSQUIT;
ENDIF;

IF(DIMIX(pDimensionDate,pTargetElementDate)=0 %
   DTYPE(pDimensionDate,pTargetElementDate)@='C');
     PROCESSQUIT;
ENDIF;

IF(TRIM(pSourceElement)@=TRIM(pTargetElement));
     PROCESSQUIT;
ENDIF;

IF(TRIM(pSourceElementDate)@=TRIM(pTargetElementDate));
     PROCESSQUIT;
ENDIF;



# process-related
IF(DATASOURCETYPE@<>'VIEW');
     PROCESSQUIT;
ENDIF;

IF(DATASOURCENAMEFORSERVER@<>vCubeName);
     PROCESSQUIT;
ENDIF;

IF(DATASOURCECUBEVIEW@<>vSourceViewName);
     PROCESSQUIT;
ENDIF;


## C. Create a view containing all data for the Source element

# 1. Tidy up the Source view
VIEWDESTROY(vCubeName,vSourceViewName);
SUBSETDESTROY(pDimensionName,vSourceSubsetName);
SUBSETDESTROY(pDimensionDate,vSourceSubsetName);


# 2. Create subset
SUBSETCREATE(pDimensionName,vSourceSubsetName);
SUBSETELEMENTINSERT(pDimensionName,vSourceSubsetName,
                    pSourceElement,1);

SUBSETCREATE(pDimensionDate,vSourceSubsetName);
SUBSETELEMENTINSERT(pDimensionDate,vSourceSubsetName,
                    pSourceElementDate,1);



# 3. Create view & assign subset
VIEWCREATE(vCubeName,vSourceViewName);
VIEWSUBSETASSIGN(vCubeName,vSourceViewName,
                 pDimensionName,vSourceSubsetName);
VIEWSUBSETASSIGN(vCubeName,vSourceViewName,
                 pDimensionDate,vSourceSubsetName);

IF(DTYPE(pDimensionName,pSourceElement)@='C');
     VIEWSETSKIPCALCS(vCubeName,vSourceViewName,0);
ENDIF;

IF(DTYPE(pDimensionDate,pSourceElementDate)@='C');
     VIEWSETSKIPCALCS(vCubeName,vSourceViewName,0);
ENDIF;

VIEWSETSKIPRULEVALUES(vCubeName,vSourceViewName,0);




## D. Zero out a view containing all data for the Target element

# 1. Tidy up
VIEWDESTROY(vCubeName,vTargetViewName);
SUBSETDESTROY(pDimensionName,vTargetSubsetName);

VIEWDESTROY(vCubeName,vTargetViewName);
SUBSETDESTROY(pDimensionDate,vTargetSubsetName);


# 2. Create subset
SUBSETCREATE(pDimensionName,vTargetSubsetName);
SUBSETELEMENTINSERT(pDimensionName,vTargetSubsetName,
                    pTargetElement,1);
SUBSETCREATE(pDimensionDate,vTargetSubsetName);
SUBSETELEMENTINSERT(pDimensionDate,vTargetSubsetName,
                    pTargetElementDate,1);


# 3. Create view & assign subset
VIEWCREATE(vCubeName,vTargetViewName);
VIEWSUBSETASSIGN(vCubeName,vTargetViewName,
                 pDimensionName,vTargetSubsetName);
VIEWSUBSETASSIGN(vCubeName,vTargetViewName,
                 pDimensionDate,vTargetSubsetName);


# 4. Zero out the view
VIEWZEROOUT(vCubeName,vTargetViewName);


# 5. Tidy up
VIEWDESTROY(vCubeName,vTargetViewName);
SUBSETDESTROY(pDimensionName,vTargetSubsetName);
SUBSETDESTROY(pDimensionDate,vTargetSubsetName);



EPILOG:

Code: Select all

# 4. Tidy up the Source view
VIEWDESTROY(vCubeName,vSourceViewName);
SUBSETDESTROY(pDimensionName,vSourceSubsetName);
SUBSETDESTROY(pDimensionDate,vSourceSubsetName);
Post Reply