dimensionelementprincipalname

Post Reply
telula_w
Posts: 15
Joined: Wed Jan 05, 2011 11:28 pm
OLAP Product: TM1
Version: 9.1
Excel Version: 2003

dimensionelementprincipalname

Post by telula_w »

I have a month dimension that has Jan,Feb,Mar,etc with attributr Mthcount as 1,2,3 etc.
I am trying to write the code to get previous month name.

prevmth=numbertostring(ATTRN('Month',pmonth,'MthCount')-1);
prevmthname=DIMENSIONELEMENTPRINCIPALNAME('Month', prevmth);

The asciioutput for prevmthname is 1 when pmonth=1;
I thought that since the Month dimension elements are Jan,Feb,Mar, the DIMENSIONELEMENTPRINCIPALNAME would give Jan or Feb or Mar ?

How then would I get the output to show elementname Jan,Feb or Mar when I only have the attribute to go by?
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: dimensionelementprincipalname

Post by Alan Kirk »

telula_w wrote:I have a month dimension that has Jan,Feb,Mar,etc with attributr Mthcount as 1,2,3 etc.
I am trying to write the code to get previous month name.

prevmth=numbertostring(ATTRN('Month',pmonth,'MthCount')-1);
prevmthname=DIMENSIONELEMENTPRINCIPALNAME('Month', prevmth);

The asciioutput for prevmthname is 1 when pmonth=1;
I thought that since the Month dimension elements are Jan,Feb,Mar, the DIMENSIONELEMENTPRINCIPALNAME would give Jan or Feb or Mar ?

How then would I get the output to show elementname Jan,Feb or Mar when I only have the attribute to go by?
Did you read the help file on what DimensionElementPrincipalName actually does?
This function returns the principal name of an element or element alias.
My emphasis. Element alias (which must be unique), not element attribute (which doesn't have to be, and which would make it impossible for TI to know which specific element you're referring to).

Rather than fluffing around with calculations (and to get around the problem of the first element's previous month being the last element of the dimension), why not simply assign the previous month's name as a string attribute to each of the 12 months and read it directly with an AttrS statement?
"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.
telula_w
Posts: 15
Joined: Wed Jan 05, 2011 11:28 pm
OLAP Product: TM1
Version: 9.1
Excel Version: 2003

Re: dimensionelementprincipalname

Post by telula_w »

yup, realised the 'alias' bit after i posted this.
Solved the problem by turning the atrribute into an alias...
Post Reply