If you are unable to create a new account, please email support@bspsoftware.com

 

Can't I use a value prompt together with parameter-based member expression?

Started by nm, 08 Jan 2025 08:10:15 AM

Previous topic - Next topic

nm

Hi,

I've a dimensional query where I want to calculate the member based on a report parameter. The expression to calculate the members looks like this:

IF(
    ?pParam? IS NULL
) THEN (
    [MyDefaultMember]
) ELSE (
    ?pParam?
)

The ?pParam? is populated by a non-required value prompt. But Cognos always forces me to enter a value. Isn't it possible to have the value prompt not to be set in such a scenario?

Best regards

bus_pass_man

If I recall correctly, the hook syntax prompt is always mandatory.  Investigate the prompt (and promptmany) functions, which have optionality and default values available.

MDXpressor

When I want to prompt for a member and have a default member in place, I use a macro in a data item expression.

#prompt('promptname', 'memberUniqueName', '[dimension].[heirarchy].[level]->[@member_address]')#

The way this prompt (and promptmany) macro works is you have 3 parameters to pass. 
1)  promptname - as it sounds, the name of the prompt (equivalent to naming your prompt with the question marks ?promptname?)
2)  the type of data the prompt is going to represent - when its an OLAP source, and your trying to get a member, this MUST say 'memberUniqueName'.  For the record, if this were relational, this could also be something 'text', or 'date', or 'integer'...
3)  is the default value that the prompt should use - in this case we are sending member unique names, so the default needs to be member of some kind.  It doesn't HAVE to be a specific address, it could be a calculation that returns a single member, but in my example I'm representing a specific address.

if you wanted the user to select many members, you would encapsulate the macro in a set() expression, and change the macro function from #prompt()# to #promptmany()#.

Here is a working example that I just copied from a report where the user can change the date that is being shown by selecting in a list prompt.  In this example, my default is more complicated than just any old member.  It selects for the latest member in the time dimension, in the event that user has not selected anything. 

#prompt('Month', 'memberUniqueName','closingPeriod([Gross Sales Cube].[History].[History].[Month])')#

Hope this is helpful...
No, a proof is a proof. What kind of a proof? It's a proof. A proof is a proof, and when you have a good proof, it's because it's proven.

-Jean Chretien