Page 1 of 1

Attribute create thru TI is only working on last element

Posted: Tue Sep 18, 2012 4:02 pm
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

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

Posted: Tue Sep 18, 2012 4:58 pm
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.

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

Posted: Tue Sep 18, 2012 6:55 pm
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.

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

Posted: Tue Sep 18, 2012 7:08 pm
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?

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

Posted: Fri Sep 21, 2012 2:26 pm
by sschreurs
Thanks Delcanr...now it works !