Prevent error on duplicate alias names - TI Process

Post Reply
BigG
Community Contributor
Posts: 211
Joined: Tue Sep 15, 2009 11:13 pm
OLAP Product: IBMPA
Version: PA 2.0 Cloud
Excel Version: 2010

Prevent error on duplicate alias names - TI Process

Post by BigG »

Hi, I have a employee list with emp number as the element name and two aliases, one emp number and name (which is always unique) and another just name (which does have duplicates). I have tried to recognise during attribute (alias) updates the duplicate 'names', but my IF statement below only works if I run the process once, If I was to reload the process will then all employee names are now not unique because they are in an element alias, therefore a concatenate occurs to make it unique...

Anyone have any further ideas?

Code: Select all

If( DIMIX('Employee',vEmployee_Name )>0);

ATTRPUTS(vEmployee_Name|' - '|vEmployee_No,'Employee',vEmployee_No,'Description');

else;
ATTRPUTS(vEmployee_Name,'Employee',vEmployee_No,'Description');

Endif;
GG
Alan Kirk
Site Admin
Posts: 6667
Joined: Sun May 11, 2008 2:30 am
OLAP Product: TM1
Version: PA2.0.9.18 Classic NO PAW!
Excel Version: 2013 and Office 365
Location: Sydney, Australia
Contact:

Re: Prevent error on duplicate alias names - TI Process

Post by Alan Kirk »

BigG wrote:Hi, I have a employee list with emp number as the element name and two aliases, one emp number and name (which is always unique) and another just name (which does have duplicates). I have tried to recognise during attribute (alias) updates the duplicate 'names', but my IF statement below only works if I run the process once, If I was to reload the process will then all employee names are now not unique because they are in an element alias, therefore a concatenate occurs to make it unique...

Anyone have any further ideas?

Code: Select all

If( DIMIX('Employee',vEmployee_Name )>0);

ATTRPUTS(vEmployee_Name|' - '|vEmployee_No,'Employee',vEmployee_No,'Description');

else;
ATTRPUTS(vEmployee_Name,'Employee',vEmployee_No,'Description');

Endif;
I'm assuming that the names can change, since women who get married still sometimes change their name and the like. (If that wasn't the case you could just do the DimIx on the number + name alias and ignore anyone who showed up.)

However since we do have that complication, one way is as follows:
(a) Use the DimIX to get the index before you hit the If block, and store it in a variable.
(b) If that's >0, then use DimensionElementPrincipalName to get the employee number that the row relates to, and store that in a variable too. This will get you the employee number of the element which already has that employee name. (Otherwise set that variable to an empty string.)
(c) The If block test then becomes IF the DimIX value = 0 then write it to description (since it doesn't exist yet), ELSE IF DimIX > 0 & the element's principal name @<> the vEmployee_No (meaning that it's a different employee), then write the expression that you currently have under the If.
"To them, equipment failure is terrifying. To me, it’s 'Tuesday.' "
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.
BigG
Community Contributor
Posts: 211
Joined: Tue Sep 15, 2009 11:13 pm
OLAP Product: IBMPA
Version: PA 2.0 Cloud
Excel Version: 2010

Re: Prevent error on duplicate alias names - TI Process

Post by BigG »

fantastic

adding

Code: Select all

 DimensionElementPrincipalName('Employee',vEmployee_Name ) @<> vEmployee_No
to the IF argument is the result I wanted.

Code: Select all

If(DIMIX('Employee',vEmployee_Name)>0 & DimensionElementPrincipalName('Employee',vEmployee_Name ) @<> vEmployee_No);

ATTRPUTS(vEmployee_Name|' - '|vEmployee_No,'Employee',vEmployee_No,'Description');
else;
ATTRPUTS(vEmployee_Name,'Employee',vEmployee_No,'Description');
Endif;
thanks Alan, you are a champion
GG
ExApplix
Posts: 103
Joined: Mon Sep 21, 2009 7:09 pm
OLAP Product: Cognos Tm1
Version: 10.2.2
Excel Version: 2016

Re: Prevent error on duplicate alias names - TI Process

Post by ExApplix »

In the TI Process if we use RECREATE instead of using UPDATE then I think we will not have to worry about this situation.

Is there any harm in using the recreate option?
Alan Kirk
Site Admin
Posts: 6667
Joined: Sun May 11, 2008 2:30 am
OLAP Product: TM1
Version: PA2.0.9.18 Classic NO PAW!
Excel Version: 2013 and Office 365
Location: Sydney, Australia
Contact:

Re: Prevent error on duplicate alias names - TI Process

Post by Alan Kirk »

ExApplix wrote:In the TI Process if we use RECREATE instead of using UPDATE then I think we will not have to worry about this situation.

Is there any harm in using the recreate option?
Two pieces.

The first is that you're relying on the accursed code wizard via the Map tab. If you want to unshackle yourself, you need to learn to do your own coding and consign anything that is thrust between the Generated Statements lines to the toxic waste centre of history. The code that's generated by the Map tab is fiddly to produce, and highly inflexible.

Second, look at what the code generates. It includes the DimensionDeleteAllElements command in the Prolog. While that statement is a necessary inclusion in the TI language, IMHO it's just too radically dangerous to use outside of a test or development environment. It essentially destroys your dimension and rebuilds it from the ground up. As long as nothing goes wrong, you won't lose any data.

But if, say, your data source is corrupted and not all of the N level elements have been added back in before the process ends, then "tears before tea time" will be an understatement.
"To them, equipment failure is terrifying. To me, it’s 'Tuesday.' "
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.
Post Reply