Attribute create thru TI is only working on last element

Post Reply
sschreurs
Posts: 3
Joined: Fri May 04, 2012 9:02 am
OLAP Product: TM1
Version: 10.1
Excel Version: 2010

Attribute create thru TI is only working on last element

Post by sschreurs »

Dear all,

I am currently working wwith version 10.1.

I'm trying to create a dimension thru a TI, and based on a csv file (list of store, represented with an ID, with a hierarchy by region and by country - attribut should be concatenation of the store ID and the store name).
Everything is perfectly working, except the attribute. After running the TI, the dimension shows all the hierarchy, well organized as required...but when I show attribut, the ID of the store has been stored as attribut in place of the store name, as requested, except for the last element of my csv file.

To ensure that there is no "hidden" issue with my csv file, I have created another TI built with the Map tab of the TI, and there it works (except that I need an attribute concatenating ID - Name). I have thus compared the Advance tabs ot the TI I've wrote with the TI built with the Map tab...and I do not see any differences.

Here is the code I've wrote:

Code: Select all

PROLOGUE:
DimName = 'Store';

IF (DimensionExists(DimName) = 0);
DimensionCreate(DimName);
ENDIF;

AttrInsert(DimName, '', 'FullName', 'A');

DimensionSortOrder(DimName, 'ByInput', 'Ascending', 'ByHierarchy',  'Ascending');

METADATA:
vElem = vCode;
L1 = Country;
L2 = Region;
vTotal = 'TOTAL STORE';

DimensionElementInsert(DimName, '', vElem,'N');
DimensionElementInsert(DimName, '', L1,'C');
DimensionElementInsert(DimName, '', L1,'C');
DimensionElementInsert(DimName, '', vTotal,'C');
DimensionElementComponentAdd(DimName, vTotal,L1, 1);
DimensionElementComponentAdd(DimName,L1,L2,1);
DimensionElementComponentAdd(DimName, L2,vElem, 1);

DATA:
vAttr = vCode | ' - ' | Store;

AttrPutS(Store, DimName, vElem, 'Full Name');
Thank you for your help
asutcliffe
Regular Participant
Posts: 164
Joined: Tue May 04, 2010 10:49 am
OLAP Product: Cognos TM1
Version: 9.4.1 - 10.1
Excel Version: 2003 and 2007

Re: Attribute create thru TI is only working on last element

Post by asutcliffe »

Hi,
sschreurs wrote:
To ensure that there is no "hidden" issue with my csv file, I have created another TI built with the Map tab of the TI, and there it works (except that I need an attribute concatenating ID - Name). I have thus compared the Advance tabs ot the TI I've wrote with the TI built with the Map tab...and I do not see any differences.
The obvious thing to look for is that it's trying to set an alias that isn't unique. This would also explain why it works if you concatenate the id and the name because this would be unique (assuming unique ids). I can't remember off the top of my head whether this would result in a minor error but expect it would.

Code: Select all

DATA:
vAttr = vCode | ' - ' | Store;

AttrPutS(Store, DimName, vElem, 'Full Name');
Note also, unless you've left out some code, you're setting the value of vAttr but not doing anything with it.
sschreurs
Posts: 3
Joined: Fri May 04, 2012 9:02 am
OLAP Product: TM1
Version: 10.1
Excel Version: 2010

Re: Attribute create thru TI is only working on last element

Post by sschreurs »

Indeed, I just make an error copy/paste the code.
For Data, i'll write this one:

vAttr = vCode | ' - ' | Store;

AttrPutS(vAttr, DimName, vElem, 'Full Name');

The point is that it doesn't work in my code whatever I concatenate or not. And all the ID for the store are unique.
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: Attribute create thru TI is only working on last element

Post by declanr »

sschreurs wrote:Dear all,

I am currently working wwith version 10.1.

I'm trying to create a dimension thru a TI, and based on a csv file (list of store, represented with an ID, with a hierarchy by region and by country - attribut should be concatenation of the store ID and the store name).
Everything is perfectly working, except the attribute. After running the TI, the dimension shows all the hierarchy, well organized as required...but when I show attribut, the ID of the store has been stored as attribut in place of the store name, as requested, except for the last element of my csv file.

To ensure that there is no "hidden" issue with my csv file, I have created another TI built with the Map tab of the TI, and there it works (except that I need an attribute concatenating ID - Name). I have thus compared the Advance tabs ot the TI I've wrote with the TI built with the Map tab...and I do not see any differences.

Here is the code I've wrote:

Code: Select all

PROLOGUE:
DimName = 'Store';

IF (DimensionExists(DimName) = 0);
DimensionCreate(DimName);
ENDIF;

AttrInsert(DimName, '', 'FullName', 'A');

DimensionSortOrder(DimName, 'ByInput', 'Ascending', 'ByHierarchy',  'Ascending');

METADATA:
vElem = vCode;
L1 = Country;
L2 = Region;
vTotal = 'TOTAL STORE';

DimensionElementInsert(DimName, '', vElem,'N');
DimensionElementInsert(DimName, '', L1,'C');
DimensionElementInsert(DimName, '', L1,'C');
DimensionElementInsert(DimName, '', vTotal,'C');
DimensionElementComponentAdd(DimName, vTotal,L1, 1);
DimensionElementComponentAdd(DimName,L1,L2,1);
DimensionElementComponentAdd(DimName, L2,vElem, 1);

DATA:
vAttr = vCode | ' - ' | Store;

AttrPutS(Store, DimName, vElem, 'Full Name');
Thank you for your help
You are declaring vElem for every row in your metadata tab but don't declare it in your data tab. That means that for every row it processes in data vElem will be equal to whatever vCode was for the LAST row of the metadata tab (last row of your source).

Just add:
vElem = vCode;
to the top of your data tab and it should do the trick.


Why are you making vElem = vCode by the way? Can't you just use vCode in the subsequent code and ignore vElem altogether?
Declan Rodger
sschreurs
Posts: 3
Joined: Fri May 04, 2012 9:02 am
OLAP Product: TM1
Version: 10.1
Excel Version: 2010

Re: Attribute create thru TI is only working on last element

Post by sschreurs »

Thanks Delcanr...now it works !
Post Reply