Hi,
In a TI process I want to add an element, say variable X, to a dimension if the element name doesn't exist (using Dimix, straightforward) and if no element has variable X as an alias within the same dimension.
I know that trying the addition will result in an error if an alias with the same name exists, and I also know I can use a while loop to test if each element's alias is the same, but is there an easier way using the inbuilt rule or Ti functions? From what I can see there is not, and I want to avoid error messages, however harmless, appearing in the message log unnecessarly.
Thanks,
Dan
Determining if an alias exists in a dimension
-
- Community Contributor
- Posts: 128
- Joined: Wed Oct 14, 2009 7:46 am
- OLAP Product: TM1
- Version: 9.4
- Excel Version: 11
- Location: London
-
- MVP
- Posts: 195
- Joined: Wed Jul 22, 2009 10:35 pm
- OLAP Product: TM1
- Version: 9.5.2 FP3
- Excel Version: 2010
Re: Determining if an alias exists in a dimension
Dan,
If you test via DimIx, if an element exists in a Dimension the function checks both basic names of elements and alias names.
So if there is an element with basic name or alias equal to 'X', DimIx will return index of such an element.
You would need iteration if you need to check for a text attribute that does need to be unique, but that is not your case from what I understand.
HTH
If you test via DimIx, if an element exists in a Dimension the function checks both basic names of elements and alias names.
So if there is an element with basic name or alias equal to 'X', DimIx will return index of such an element.
You would need iteration if you need to check for a text attribute that does need to be unique, but that is not your case from what I understand.
HTH
-
- MVP
- Posts: 2836
- Joined: Tue Feb 16, 2010 2:39 pm
- OLAP Product: TM1, Palo
- Version: Beginning of time thru 10.2
- Excel Version: 2003-2007-2010-2013
- Location: Atlanta, GA
- Contact:
Re: Determining if an alias exists in a dimension
The ElementName argument of DIMIX, i.e., DIMIX(DimName,ElementName) can either be an actual element name OR an alias so if you DIMIX with the element you want to add it will return a value of greater than 1 if either that actual element already exists or it is an alias of another element that already exists.
-
- Community Contributor
- Posts: 128
- Joined: Wed Oct 14, 2009 7:46 am
- OLAP Product: TM1
- Version: 9.4
- Excel Version: 11
- Location: London
-
- MVP
- Posts: 3706
- Joined: Fri Mar 13, 2009 11:14 am
- OLAP Product: TableManager1
- Version: PA 2.0.x
- Excel Version: Office 365
- Location: Switzerland
Re: Determining if an alias exists in a dimension
I think I get what you're trying to do an yes there is an easier way than looping through all attributes for the member and checking against the values for DTYPE 'AA'. Here is some (untested) code which check against both DIMIX and DimensionElementPrincipalNamedan.kelleher wrote:Hi,
In a TI process I want to add an element, say variable X, to a dimension if the element name doesn't exist (using Dimix, straightforward) and if no element has variable X as an alias within the same dimension.
I know that trying the addition will result in an error if an alias with the same name exists, and I also know I can use a while loop to test if each element's alias is the same, but is there an easier way using the inbuilt rule or Ti functions? From what I can see there is not, and I want to avoid error messages, however harmless, appearing in the message log unnecessarly.
Thanks,
Dan
Code: Select all
## This code on META DATA ##
IF( DIMIX(cDim, sNewEle) = 0 );
# the new element is unique, let's add it
DimensionElementInsert(cDim, '', sNewEle, 'N');
Else;
sPrincipalNm = DimensionElementPrincipalName(cDim, sNewEle);
IF( sNewEle @= sPrincipalNm );
# the new element matches the name of an already exusting element so we can't add it
ItemReject(sNewEle | ' matches a pre-existing element principal name');
Else;
# the new element matches the alias of an already exusting element so we can't add it
ItemReject(sNewEle | ' matches an alias value of element ' | sPrincipalNm);
EndIF;
EndIF;