Different Hierarchy in Same Dimension
-
- Posts: 128
- Joined: Thu Dec 15, 2011 8:22 pm
- OLAP Product: TM1
- Version: 9.4
- Excel Version: 2003
Different Hierarchy in Same Dimension
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.
I need a samplecode for this
Anyone can give me a link for this and any sample code to go through.
-
- MVP
- Posts: 3240
- Joined: Mon Dec 29, 2008 6:26 pm
- OLAP Product: TM1, Jedox
- Version: PAL 2.1.5
- Excel Version: Microsoft 365
- Location: Brussels, Belgium
- Contact:
Re: Different Hierarchy in Same Dimension
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.
Elements and consolidations setup is done with DimensionElementInsert and DimensionElementComponentAdd.
For attributes: AttrInsert and AttrPutS.
The TM1 manual explains the arguments to be used.
Best regards,
Wim Gielis
IBM Champion 2024-2025
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
Wim Gielis
IBM Champion 2024-2025
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
-
- Posts: 128
- Joined: Thu Dec 15, 2011 8:22 pm
- OLAP Product: TM1
- Version: 9.4
- Excel Version: 2003
Re: Different Hierarchy in Same Dimension
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;
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;
-
- MVP
- Posts: 600
- Joined: Wed Aug 17, 2011 1:19 pm
- OLAP Product: TM1
- Version: 9.5.2 10.1 10.2
- Excel Version: 2003 2007
- Location: York, UK
Re: Different Hierarchy in Same Dimension
If you have "None" against a source field it will not create a variable. You need to have "Other".
-
- MVP
- Posts: 3240
- Joined: Mon Dec 29, 2008 6:26 pm
- OLAP Product: TM1, Jedox
- Version: PAL 2.1.5
- Excel Version: Microsoft 365
- Location: Brussels, Belgium
- Contact:
Re: Different Hierarchy in Same Dimension
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
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
Best regards,
Wim Gielis
IBM Champion 2024-2025
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
Wim Gielis
IBM Champion 2024-2025
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
-
- 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: Different Hierarchy in Same Dimension
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.)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
Declan Rodger
-
- MVP
- Posts: 3240
- Joined: Mon Dec 29, 2008 6:26 pm
- OLAP Product: TM1, Jedox
- Version: PAL 2.1.5
- Excel Version: Microsoft 365
- Location: Brussels, Belgium
- Contact:
Re: Different Hierarchy in Same Dimension
What could that "something else" be in a TM1 process ?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.)

Best regards,
Wim Gielis
IBM Champion 2024-2025
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
Wim Gielis
IBM Champion 2024-2025
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
-
- 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: Different Hierarchy in Same Dimension
Well I think that the actual quote is a bit difficult to decipher: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.
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:
And Duncan pointed out:declanr wrote:What do you have on your variables tab?
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...Duncan P wrote:If you have "None" against a source field it will not create a variable. You need to have "Other".
Declan Rodger
-
- Posts: 128
- Joined: Thu Dec 15, 2011 8:22 pm
- OLAP Product: TM1
- Version: 9.4
- Excel Version: 2003
Re: Different Hierarchy in Same Dimension
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..
-
- 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: Different Hierarchy in Same Dimension
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.
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.
Declan Rodger
-
- Posts: 128
- Joined: Thu Dec 15, 2011 8:22 pm
- OLAP Product: TM1
- Version: 9.4
- Excel Version: 2003
Re: Different Hierarchy in Same Dimension
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.
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.
-
- MVP
- Posts: 3240
- Joined: Mon Dec 29, 2008 6:26 pm
- OLAP Product: TM1, Jedox
- Version: PAL 2.1.5
- Excel Version: Microsoft 365
- Location: Brussels, Belgium
- Contact:
Re: Different Hierarchy in Same Dimension
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.
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.
Best regards,
Wim Gielis
IBM Champion 2024-2025
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
Wim Gielis
IBM Champion 2024-2025
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
-
- Posts: 128
- Joined: Thu Dec 15, 2011 8:22 pm
- OLAP Product: TM1
- Version: 9.4
- Excel Version: 2003
Re: Different Hierarchy in Same Dimension
Thanks wim for your reply...I will test this and will come back to you...