Alias to Element

Post Reply
winsonlee
Regular Participant
Posts: 180
Joined: Thu Jul 01, 2010 3:06 am
OLAP Product: Cognos Express
Version: 9.5
Excel Version: 2007
Location: Melbourne, Australia

Alias to Element

Post 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 ?
User avatar
paulsimon
MVP
Posts: 808
Joined: Sat Sep 03, 2011 11:10 pm
OLAP Product: TM1
Version: PA 2.0.5
Excel Version: 2016
Contact:

Re: Alias to Element

Post 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
User avatar
Steve Vincent
Site Admin
Posts: 1054
Joined: Mon May 12, 2008 8:33 am
OLAP Product: TM1
Version: 10.2.2 FP1
Excel Version: 2010
Location: UK

Re: Alias to Element

Post 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.
If this were a dictatorship, it would be a heck of a lot easier, just so long as I'm the dictator.
Production: Planning Analytics 64 bit 2.0.5, Windows 2016 Server. Excel 2016, IE11 for t'internet
Post Reply