Page 1 of 1

Alias to Element

Posted: Tue Mar 08, 2011 10:59 pm
by winsonlee
I have data file having the alias value instead of the element value.

APN is the alias for ProductCode.

Normally for element i would be doing

IF( DIMIX(DimensionProduct, ProductCode) = 0);
DimensionElementComponentAdd(DimensionProduct, 'All Products', ProductCode, 1);
ENDIF;

But i have tried the following and it doesnt seems to be working as APN is an alias to ProductCode but it is treating APN is an element and check if APN does exist as an element in the dimension.

IF( DIMIX(DimensionProduct, APN) = 0);
DimensionElementComponentAdd(DimensionProduct, 'All Products', APN, 1);
ENDIF;


I am trying to add data using an alias name and the statement below works for those that has an alias for ProductCode and generate an error for those whose alias does not exist within the dimension.
CELLPUTN(SOH,CubeName,Year2,'Final','Week '|CalandarWeek,Store,APN,'SOH');


did i miss out something ?

Re: Alias to Element

Posted: Wed Mar 09, 2011 12:33 am
by paulsimon
Hi

I am not sure that I fully understand the issue, however, there are a couple of things that might help:

To get the underlying element name from an alias you can do two things

Use the DimensionElementPrincipalName TI Function or use the old dimnm( dim, dimix( dim, elem))

Depending on your version there used to be an issue with the MetaData failing to insert elements if all the code was within IFs. A work around was to have at least on statement that was not in an IF, even if it was inserting an element that already existed in the dimension, it still forced TM1 to update the dimension properly.

Regards

Paul Simon

Re: Alias to Element

Posted: Wed Mar 09, 2011 4:25 pm
by Steve Vincent
winsonlee wrote:
IF( DIMIX(DimensionProduct, ProductCode) = 0);
DimensionElementComponentAdd(DimensionProduct, 'All Products', ProductCode, 1);
ENDIF;

IF( DIMIX(DimensionProduct, APN) = 0);
DimensionElementComponentAdd(DimensionProduct, 'All Products', APN, 1);
ENDIF;
If your alias doesn't exist it means the element it belongs to doesn't exist either. You'd have to add the element first, then update the alias with AttrPutS. Problem is if your file only has the alias value then this code is no use to you. You either need to get the element value in the source as well, or find a different way to maintain the dimension.