Different Hierarchy in Same Dimension

Post Reply
dilip
Posts: 128
Joined: Thu Dec 15, 2011 8:22 pm
OLAP Product: TM1
Version: 9.4
Excel Version: 2003

Different Hierarchy in Same Dimension

Post 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.
Wim Gielis
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

Post 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.
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
dilip
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

Post 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;
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: Different Hierarchy in Same Dimension

Post by declanr »

What do you have on your variables tab?
Declan Rodger
Duncan P
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

Post by Duncan P »

If you have "None" against a source field it will not create a variable. You need to have "Other".
Wim Gielis
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

Post 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
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
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: Different Hierarchy in Same Dimension

Post 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.)
Declan Rodger
Wim Gielis
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

Post 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.
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
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: Different Hierarchy in Same Dimension

Post 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...
Declan Rodger
dilip
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

Post 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..
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: Different Hierarchy in Same Dimension

Post 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.
Declan Rodger
dilip
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

Post 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.
Wim Gielis
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

Post 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.
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
dilip
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

Post by dilip »

Thanks wim for your reply...I will test this and will come back to you...
Post Reply