Alias of an Element

Post Reply
samuvk
Posts: 9
Joined: Wed Jan 27, 2010 9:53 pm
OLAP Product: TM1
Version: v9.0
Excel Version: 2003

Alias of an Element

Post by samuvk »

Hi All,

Everything is going much easier now, thanks to all you guys, but I'm still have questions and problems.

I'm trying to get the Alias of an element in a Dimension.

Trying to use this code:

Code: Select all

  Dim Element As String
  Dim l_DimIdx As Long
  Dim Alias As String

  l_DimIdx = 1
  
  Element = Application.Run("DIMNM", Server & ":" & Dimension, l_DimIdx, Alias)
If for instance I have a Element named Co.52 which Alias is "A Bank" I'm getting in Alement Co.52 and I'm trying to get "A Bank".

Thank you for all your help again
User avatar
Mike Cowie
Site Admin
Posts: 483
Joined: Sun May 11, 2008 7:07 pm
OLAP Product: IBM TM1/PA, SSAS, and more
Version: Anything thru 11.x
Excel Version: 2003 - Office 365
Location: Alabama, USA
Contact:

Re: Alias of an Element

Post by Mike Cowie »

Hi:

Try using the DBRA TM1 function to get the alias:

Code: Select all

  Dim Element As String
  Dim AliasAttributeName As String
  Dim AliasValue As String
  Dim l_DimIdx As Long

  AliasAttributeName = "<Your Alias Name Goes Here>"
  l_DimIdx = 1
  
  Element = Application.Run("DIMNM", Server & ":" & Dimension, l_DimIdx)
  AliasValue = Application.Run("DBRA", Server & ":" & Dimension, Element, AliasAttributeName)

Hope that helps!

Regards,
Mike
Mike Cowie
QueBIT Consulting, LLC

Are you lost without Print Reports in Planning Analytics for Excel (PAfE)? Get it back today, for free, with Print Reports for IBM Planning Analytics for Excel!
Alan Kirk
Site Admin
Posts: 6647
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: Alias of an Element

Post by Alan Kirk »

samuvk wrote: I'm trying to get the Alias of an element in a Dimension.

Trying to use this code:

Code: Select all

  Dim Element As String
  Dim l_DimIdx As Long
  Dim Alias As String

  l_DimIdx = 1
  
  Element = Application.Run("DIMNM", Server & ":" & Dimension, l_DimIdx, Alias)
If for instance I have a Element named Co.52 which Alias is "A Bank" I'm getting in Alement Co.52 and I'm trying to get "A Bank".
There are several problems there.

The first is that while DimNm can return an alias, that isn't its primary role. DimNm is for when you need to specify the position number (index) of an element in a dimension, and want to get the name of the element that's in that position. DimNm will return that name, optionally using an alias.

The code that you have above will always return the name of first element in the dimension, regardless of which one that is.

The second problem is that you haven't populated the Alias string variable with the name of the alias that you want. That means that you'll be passing an empty string to the last argument of DimNm, and that means that you'll just be getting the base name of the element (presumably "Co.52") as you described.

If all you want is the alias, and you want to specify the element that you want the alias for, you may as well use DBRA instead of DimNm:

Code: Select all

Sub AliasDisplay(Server As String, Dimension As String)

Dim s_ElementBaseName As String
Dim s_ElementAlias As String
Dim s_Alias As String

'You'd more likely pass this as a further argument.
s_ElementBaseName = "Co.52"

'You need to specify which alias you want rteturned; let's
'suppose that the alias is called "Desc".
s_Alias = "Desc"

s_ElementAlias = Application.Run("DBRA", _
 Server & ":" & Dimension, s_ElementBaseName, s_Alias)

MsgBox s_ElementAlias

End Sub
Edit: Ooops, Mike beat me to it...
"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