COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: suhas_bhat on 15 Sep 2010 06:17:11 AM

Title: How to return the level number of a member?
Post by: suhas_bhat on 15 Sep 2010 06:17:11 AM
Hi all,
   I am facing an issue which goes like this.
I a have a value prompt that displays members of a hierarchy viz. a,b,c,d where b i s a child of a and c is a child of b and so on, the source for the value prompt is the hierarchy itself.
Now when i select the member i want to use the level number that the member belongs to. Which function can i use to access the level number of the member? What would the code look like?
Please help. ???
Title: Re: How to return the level number of a member?
Post by: CognosPaul on 15 Sep 2010 07:04:16 AM
Two ways

ordinal(#prompt('member','memberuniquename','','','[ns].[dim].[hierarchy]')#)
or
roleValue('_levelNumber',#prompt('member','memberuniquename','','','[ns].[dim].[hierarchy]')#)

The ordinal will work with all cubes. The _levelNumber may not work with some dimensional sources.

A small trick: in the insertable objects pane, open any hierarchy to a member. Right click on that member and click Properties. You can reference any of the attributes there with the roleValue function:
First word is always preceded by an underscore _ and first word is always lowercase, the first character of all subsequent words are capitalized
rolevalue('_firstSecond',[member])
rolevalue('_path',currentMember([ns].[dim].[hier]))
Title: Re: How to return the level number of a member?
Post by: suhas_bhat on 15 Sep 2010 10:53:54 PM
This is fantastic stuff Paul, Thanks a ton!

Since i am using a value prompt i don't want to hard code the member name, i tried using it like this
roleValue('_levelNumber',?parameter_name?) - this throws invalid prompt use errors.

What would be the right way to use this?
Title: Re: How to return the level number of a member?
Post by: CognosPaul on 16 Sep 2010 03:55:45 AM
Well, it depends on what's being passed to the prompt.

A few possible scenarios that would get you that error:


Try this:

roleValue('_levelNumber',#prompt('parameter_name','memberuniquename','','','[ns].[dim].[hierarchy]')#)

replace the [ns].[dim].[hierarchy] with the hierarchy you're using.