Page 1 of 1

Different Hierarchy in Same Dimension

Posted: Fri Jul 17, 2015 1:09 pm
by dilip
How we can create 2 hierarchy within a same dimension,Iam learning TM1 development on my own.I have 2 files for same dimensionand each file contains name of element and attribute column and each file contains more than 5 columns with a different hierchy in each file but with same element names and columns.

I need a samplecode for this

Anyone can give me a link for this and any sample code to go through.

Re: Different Hierarchy in Same Dimension

Posted: Fri Jul 17, 2015 6:44 pm
by Wim Gielis
Hello

Elements and consolidations setup is done with DimensionElementInsert and DimensionElementComponentAdd.
For attributes: AttrInsert and AttrPutS.

The TM1 manual explains the arguments to be used.

Re: Different Hierarchy in Same Dimension

Posted: Sun Jul 19, 2015 12:34 pm
by dilip
I was writing this code in TI..I have selected as None.

My source file abc.txt looks like this:-
Product,color1,product2,color2
A,Green,B,White
D,Black,E,Yellow

TI code as given below to read my file abc.txt.
Its always giving me an error product variable is undefined...I dont understand why it is throwing tis error product is already present in my source file.....

vDim='HierchyDim3';

Datasourcenameforserver='D:\sourcefiles_TM1\abc.txt';


DataSourceType = 'CHARACTERDELIMITED';

#DatasourceNameForServer = P0;

asciioutput('D:\sourcefiles_TM1\output.txt',datasourcenameforserver);

#Datasourcename=

DIMENSIONDESTROY(vDim);
DIMENSIONCREATE(vDim);
DIMENSIONSORTORDER(vDim,'','','BYINPUT','ASCENDING');
ATTRDELETE(vDim,'color1');
ATTRINSERT(vDim,'','color1','S');
ATTRDELETE(vDim,'color2');
ATTRINSERT(vDim,'','color2','S');
DIMENSIONELEMENTINSERT(vDim,'',product,'s');
DIMENSIONELEMENTINSERT(vDim,'',Product2,'s');

if ('|P0|'@='abc.txt');


DimensionElementComponentAdd(vDim,product,product2,0);
ATTRPUTS(color1,vDim,Product,'color1');
ATTRPUTS(color2,vDim,product2,'color2');

else;

DimensionElementComponentAdd('HierarchyDim3',Product2,product,0);
ATTRPUTS(color2,vDim,Product,'color2');
ATTRPUTS(color1,vDim,product2,'color1');

endif;

Re: Different Hierarchy in Same Dimension

Posted: Sun Jul 19, 2015 2:45 pm
by declanr
What do you have on your variables tab?

Re: Different Hierarchy in Same Dimension

Posted: Sun Jul 19, 2015 9:29 pm
by Duncan P
If you have "None" against a source field it will not create a variable. You need to have "Other".

Re: Different Hierarchy in Same Dimension

Posted: Mon Jul 20, 2015 8:48 am
by Wim Gielis
Hello

Even though you have:

DataSourceType = 'CHARACTERDELIMITED';

I would not start from None as a Data source.
I would choose a text file as datasource, it could be a dummy file but with the same columns as the file you are trying to import.
Certainly not use None as Data source.

Wim

Re: Different Hierarchy in Same Dimension

Posted: Mon Jul 20, 2015 9:16 am
by declanr
Wim Gielis wrote:Hello

Even though you have:

DataSourceType = 'CHARACTERDELIMITED';

I would not start from None as a Data source.
I would choose a text file as datasource, it could be a dummy file but with the same columns as the file you are trying to import.
Certainly not use None as Data source.

Wim
I'm assuming where Dilip mentioned selecting "None" he may have been referring to something else other than datasource as doing that would lock the Metadata and Data tabs anyway (although the code doesn't specify which tabs it is on I do assume it is on the meta/data tabs.)

Re: Different Hierarchy in Same Dimension

Posted: Mon Jul 20, 2015 9:41 am
by Wim Gielis
declanr wrote:I'm assuming where Dilip mentioned selecting "None" he may have been referring to something else other than datasource as doing that would lock the Metadata and Data tabs anyway (although the code doesn't specify which tabs it is on I do assume it is on the meta/data tabs.)
What could that "something else" be in a TM1 process ? :-) Maybe it's just a typo and it should have been Text.

Re: Different Hierarchy in Same Dimension

Posted: Mon Jul 20, 2015 9:48 am
by declanr
Wim Gielis wrote: What could that "something else" be in a TM1 process ? :-) Maybe it's just a typo and it should have been Text.
Well I think that the actual quote is a bit difficult to decipher:
dilip wrote:I was writing this code in TI..I have selected as None.

But based on the rest of the code and error being received I think what I was eluding to:
declanr wrote:What do you have on your variables tab?
And Duncan pointed out:
Duncan P wrote:If you have "None" against a source field it will not create a variable. You need to have "Other".
Might be the culprit... having said that now that I look at it further... with metadata and data statements right next to each other in the remaining code; you could very well be right and the whole lot of code has been put on the Prolog or Epilog anyway. Which of course is a whole other issue...

Re: Different Hierarchy in Same Dimension

Posted: Mon Jul 20, 2015 7:56 pm
by dilip
As I was using none option in datasource so metadata and data tabs are hidden so all code iam writing in Prolog.....Also my requirement is that I can choose source file dynamically using different files using parameter variable so that it build one hierchy eg A,B,C using abc.txt file. and C,A,B using def.txt file..

Re: Different Hierarchy in Same Dimension

Posted: Mon Jul 20, 2015 8:17 pm
by declanr
If you want to work on data from a datasource you NEED a datasource selected for your TI.
And only the metadata and data tabs can read data from that source.
Prolog and epilog tabs are external to your source data.

Start off by breaking up the code into the relevant tabs and then work on making the source dynamic as a second step; it will be much easier to follow if you tackle your goals one step at a time.

Re: Different Hierarchy in Same Dimension

Posted: Tue Jul 21, 2015 1:29 pm
by dilip
Thanks declanr.
I need to know 1 thing "Can we move data from one base level element to other consolidated from 1 cube to another having all the dimensions and its members same in all dimension except in 1 dimension where the base level element in 1 dimension of cube Ist and same element is consolidated in cube 2nd and I want to move data for that element from 1 cube to another..Is it possible..and how we can do??If anyone can answer my question...

This is somewhat different from thread main question but I want to know regarding this.

Re: Different Hierarchy in Same Dimension

Posted: Tue Jul 21, 2015 4:39 pm
by Wim Gielis
Usually it is the other way round: from a consolidated element to an n-type element.

But if you insist. You cannot write to the C-level element directly. So you will need to write to a child of that consolidation.
If you don't have such child, create one.
If you try to spread a value proportionally, have a look at CellPutProportionalSpread.

Re: Different Hierarchy in Same Dimension

Posted: Fri Jul 24, 2015 11:04 am
by dilip
Thanks wim for your reply...I will test this and will come back to you...