Please Help the Hold firt cell data PLSSS

Post Reply
AliUgur
Posts: 58
Joined: Tue Aug 05, 2014 2:13 pm
OLAP Product: TM1
Version: TM1 10.2.2
Excel Version: Excel 2013

Please Help the Hold firt cell data PLSSS

Post by AliUgur »

Hi everybody ,
ı have two cubes..A and B.. ı m trying to move the data from A to B. But the thing is some of item's of A cube needs to be sum up then move to B cube my codes are here .. First data comes but when the second data comes fırst data goes. ı need to keep fırst data and sum on second data.. Pls help asap..

İliski = CellGetS('}ElementAttributes_2_Hesap_Planı',V_Kalemler, 'Mali_Tablo_Secimi');
Secim = CellGetS('}ElementAttributes_2_Hesap_Planı',V_Kalemler, 'TP_YP_Secimi');

CellPutN(0, 'TM1_Mali_Tablo',İliski,Secim,'Solo',P_Ay,P_Senaryo,'MİZAN');

Data = CellGetN('Mizan',V_Kalemler, P_Ay, P_Senaryo,'FİNAL MİZAN');

CellPutN(Data, 'TM1_Mali_Tablo',İliski,Secim,'Solo',P_Ay,P_Senaryo,'MİZAN');

EskiDeger=CellGetN('TM1_Mali_Tablo',İliski,Secim,'Solo',P_Ay,P_Senaryo,'MİZAN');

CellPutN(EskiDeger+Data, 'TM1_Mali_Tablo',İliski,Secim,'Solo',P_Ay,P_Senaryo,'MİZAN');
declanr
MVP
Posts: 1831
Joined: Mon Dec 05, 2011 11:51 am
OLAP Product: Cognos TM1
Version: PA2.0 and most of the old ones
Excel Version: All of em
Location: Manchester, United Kingdom
Contact:

Re: Please Help the Hold firt cell data PLSSS

Post by declanr »

First of all there was no need for you to post 2 topics that seem exactly the same (http://www.tm1forum.com/viewtopic.php?f=3&t=10740) but as to your question, it is difficult to give you exact code without knowing about the dimensionality of your source and destination cubes.

Roughly what you need to do:
AliUgur wrote: CellPutN(0, 'TM1_Mali_Tablo',İliski,Secim,'Solo',P_Ay,P_Senaryo,'MİZAN');
I assume you are doing this to zero out the old data prior to loading in new data, get rid of this. This code will only zero out items in the destination if values for those cell points also exist in the source (i.e. if you had a value of 200 in a cell last time you loaded it but have nothing to overwrite it with this time then the 200 will remain.)

Instead in your prolog tab use ViewCreate(), SubsetCreate (), SubsetElementInsert(), SubsetCreateByMDX(), ViewSubsetAssign(), ViewZeroOut() etc to create a temporary view of the destination and then clear the data prior to loading in new data (there are MANY posts on the forum explaining how to do just this if you are unsure.


Second of all create your source view on your source cube in the prolog also. In the process of doing this create a temporary consolidation of the 2 measure elements that you want to add together:

Code: Select all

sConsol = 'Temp Consolidation';
DimensionElementInsert ( sDimMeasures, '', sConsol, 'c' );
DimensionElementComponentAdd ( sDimMeasures, sConsol, 'FINAL MIZAN', 1 );
DimensionElementComponentAdd ( sDimMeasures, sConsol, <whatever the other element you want to include is>, 1 );
Then assign that element to your source view:

Code: Select all

If ( SubsetExists ( sDimMeasures, sSubsetName ) = 0 );
     SubsetCreate ( sDimMeasures, sSubsetName );
Else;
     SubsetDeleteAllElements ( sDimMeasures, sSubsetName );
EndIf;
SubsetElementInsert ( sDimMeasures, sSubsetName, sConsol, 1 );
ViewSubsetAssign ( sCubSource, sViewSource, sDimMeasures, sSubsetName )
Also Create level 0 subsets for all the other dimensions in the cube (or at whatever level you need to load - i.e. what exists in the destination cube) then assign them to the view.

Make sure to set SkipCalcs to 0 and SkipZeroes to 1 (still in the prolog):

Code: Select all

ViewExtractSkipCalcsSet ( sCubSource, sViewSource, 0 );
ViewExtractSkipZeroesSet ( sCubSource, sViewSource, 1 );

DataSourceType = 'View';
DataSourceNameForSever = sCubSource;
DataSourceCubeView = sViewSource;
Then in your data tab you can do a simple CellPutN without having to retrieve any extra values.

In the epilog be sure to delete your Views, subsets and the temporary consolidation.


Back to what you already have done (for info) there is no need to do both of these lines:
AliUgur wrote: CellPutN(Data, 'TM1_Mali_Tablo',İliski,Secim,'Solo',P_Ay,P_Senaryo,'MİZAN');
CellPutN(EskiDeger+Data, 'TM1_Mali_Tablo',İliski,Secim,'Solo',P_Ay,P_Senaryo,'MİZAN');
Since the second line would overwrite the first line EVERY time, making the first line completely redundant.
Declan Rodger
AliUgur
Posts: 58
Joined: Tue Aug 05, 2014 2:13 pm
OLAP Product: TM1
Version: TM1 10.2.2
Excel Version: Excel 2013

Re: Please Help the Hold firt cell data PLSSS

Post by AliUgur »

First of all sorry for creating two topics for one solution.. After that thanks for replying to my question..
As i read your answer , but the thing is not same item will sum up and feed another item.. items will change .. Let me explain ,
Ive two cubes and A cube(item= 10,11,12,13,14,15,16,17...) and B cube(A,B,C,D...)
from A Cube,10+11 =A but maybe 13+15+17=C
it will work in this way... I get the datas with these codes But the thing is for example item 10`s value 5 and item 11`s value 6 the result comes like 12 cause it put the 5 first
then at the second round puts the 6 .. after all of this Eskideger=6 and data= 6 thats why eskideger+data=12 but i need eskideger+data= 11(5+6)

Data = CellGetN('Mizan',V_Kalemler, P_Ay, P_Senaryo,'FİNAL MİZAN');

CellPutN(Data, 'TM1_Mali_Tablo',İliski,Secim,'Solo',P_Ay,P_Senaryo,'MİZAN');

EskiDeger=CellGetN('TM1_Mali_Tablo',İliski,Secim,'Solo',P_Ay,P_Senaryo,'MİZAN');

CellPutN(EskiDeger+Data, 'TM1_Mali_Tablo',İliski,Secim,'Solo',P_Ay,P_Senaryo,'MİZAN');

i hope i explained well...What do you think guys? Thanks for respond...
Andy Key
MVP
Posts: 352
Joined: Wed May 14, 2008 1:37 pm
OLAP Product: TM1
Version: 2.5 to PA
Excel Version: Lots
Location: Sydney
Contact:

Re: Please Help the Hold firt cell data PLSSS

Post by Andy Key »

If you use the ViewZeroOut on Cube B as Declan has suggested, you can then use CellIncrementN rather than CellPutN.

I'm assuming that one of these:

Code: Select all

İliski = CellGetS('}ElementAttributes_2_Hesap_Planı',V_Kalemler, 'Mali_Tablo_Secimi');
Secim = CellGetS('}ElementAttributes_2_Hesap_Planı',V_Kalemler, 'TP_YP_Secimi');
is giving your example lookup from '10' and '11' to 'A', with the other one doing another mapping.

If we also assume that your TI process is using 'FİNAL MİZAN' as it's data source and that this is assigned as V_Value on the Variables tab:

Code: Select all

CellIncrementN( V_Value, 'TM1_Mali_Tablo',İliski,Secim,'Solo',P_Ay,P_Senaryo,'MİZAN');
Andy Key
BariAbdul
Regular Participant
Posts: 424
Joined: Sat Mar 10, 2012 1:03 pm
OLAP Product: IBM TM1, Planning Analytics, P
Version: PAW 2.0.8
Excel Version: 2019

Re: Please Help the Hold firt cell data PLSSS

Post by BariAbdul »

This code will only zero out items in the destination if values for those cell points also exist in the source (i.e. if you had a value of 200 in a cell last time you loaded it but have nothing to overwrite it with this time then the 200 will remain.)
Hi declanr,Sorry,Please bear with my ignorance once more,My understanding was CellPutN would put the value we defining, overwriting over whatever existing value in the defined intersection,Please correct me.Thanks
"You Never Fail Until You Stop Trying......"
declanr
MVP
Posts: 1831
Joined: Mon Dec 05, 2011 11:51 am
OLAP Product: Cognos TM1
Version: PA2.0 and most of the old ones
Excel Version: All of em
Location: Manchester, United Kingdom
Contact:

Re: Please Help the Hold firt cell data PLSSS

Post by declanr »

BariAbdul wrote:
This code will only zero out items in the destination if values for those cell points also exist in the source (i.e. if you had a value of 200 in a cell last time you loaded it but have nothing to overwrite it with this time then the 200 will remain.)
Hi declanr,Sorry,Please bear with my ignorance once more,My understanding was CellPutN would put the value we defining, overwriting over whatever existing value in the defined intersection,Please correct me.Thanks
As a rough example; you have 2 like for like cubes. If you have 20 data points in your destination that are populated with "100" and your source cube has 10 data points that are populated with "200" and the other 10 are blank/0.

Having suppress zeroes on in your source and then the following code:

Code: Select all

CellPutN ( Value, sDestination, v1, v2, 'amount' );
You will end up with 10 cells showing 100 and 10 showing 200 in your destination so that it no longer equals your source. If you add a ViewZeroOut() in the prolog of your process however you would end up with your source and destination cubes being the same.
Declan Rodger
BariAbdul
Regular Participant
Posts: 424
Joined: Sat Mar 10, 2012 1:03 pm
OLAP Product: IBM TM1, Planning Analytics, P
Version: PAW 2.0.8
Excel Version: 2019

Re: Please Help the Hold firt cell data PLSSS

Post by BariAbdul »

Thanks declanr.Appreciate your help.
"You Never Fail Until You Stop Trying......"
AliUgur
Posts: 58
Joined: Tue Aug 05, 2014 2:13 pm
OLAP Product: TM1
Version: TM1 10.2.2
Excel Version: Excel 2013

Re: Please Help the Hold firt cell data PLSSS

Post by AliUgur »

I will use you guys's advices and ı hope ı wıll have the rıght result.. Thanks alot guys for helpıng me .. Thıs ıs a good TM1blog as I c. thanks agaın..=)
AliUgur
Posts: 58
Joined: Tue Aug 05, 2014 2:13 pm
OLAP Product: TM1
Version: TM1 10.2.2
Excel Version: Excel 2013

Re: Please Help the Hold firt cell data PLSSS

Post by AliUgur »

Hi guys,
I tried you guys 's advices but ı couldnt get the result.. I dıd the ViewZeroOut() function it Works.. After that, whıch you said to set up a view from source cube ı did the on variables part ı created the sour cube view whıch the data wıll come from.. The thing are in here,
My first cube values are 1,2,3,4,5,6,7,8,9,10
My second cube values are A,B, C, D, E,F,G..
For example, from first cube while (1+3+5)=A data transferin the A, (6+7+9)=D data transfering the D(Also ı am gonna write this by TI)
User will choose the Month and Scenario as parameter then process will start

these codes for attribute because in the first cube and the second cube items are different thats why for first cube item 1's attribute is A, 3's attribute is A, 5's attribute is A.. then with 'Mali_Tablo_Secimi' attribute gives me the which item second cube data will go(I hope ı explaıned well)

İliski = CellGetS('}ElementAttributes_2_Hesap_Planı',V_Kalemler, 'Mali_Tablo_Secimi');
Secim = CellGetS('}ElementAttributes_2_Hesap_Planı',V_Kalemler, 'TP_YP_Secimi');

After that,

I am getting the data from first cube with cellGetN,

Data = CellGetN('Mizan',V_Kalemler,P_Ay,P_Versiyon,'FİNAL MİZAN');

Then I need to put the data to second cube but whıle ı m puttıng it ı need to make a lıttle calculatıon rıght?(1+3+5=A)
CellPutN(Data , 'TM1_Mali_Tablo',İliski,Secim,'Solo',P_Ay,P_Senaryo,'MİZAN');
OldValue = CellGetN('TM1_Mali_Tablo',İliski,Secim,'Solo',P_Ay,P_Senaryo,'MİZAN');
CellPutN(OldValue+Data, 'TM1_Mali_Tablo',İliski,Secim,'Solo',P_Ay,P_Senaryo,'MİZAN');

but the thing is here with these codes,

it doesn make the calculation, it puts the last value whıch is '5', but need the put '1+3+5'
What is the solution?

Also ı couldnt use the CellIncrementN.. Thats why maybe u guys can help me for that problem
AliUgur
Posts: 58
Joined: Tue Aug 05, 2014 2:13 pm
OLAP Product: TM1
Version: TM1 10.2.2
Excel Version: Excel 2013

Re: Please Help the Hold firt cell data PLSSS

Post by AliUgur »

I just use the CellIncrementN() function but ıt accumulate the same data 3 times .. Any advice for that? is it about the view or?
Post Reply