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

Author Topic: Prompt in FM for Query Studio  (Read 25112 times)

cognos_users

  • Guest
Prompt in FM for Query Studio
« on: 30 Mar 2009 09:55:03 am »
Hi All,

I have to define a mandatory prompt in Framework Manager within a query subject so that whenever a user pulls a column from that query subject in QS, he will be prompted for a value.
now the problem is the prompt type that cognos gives is an Edit Box prompt. Instead of this I need a Select Value prompt. I have tried by changing the Prompt Info property of the query item to Select Value, but still it is giving as an Edit box.

When the 'Usage' of the prompt is changed from 'Always' to 'Optional', Select Value prompt is given but it is not prmpting unless the run button is hit in QS.

Can anyone tell me is this the way Cognos works or i can achieve this somehow?

PS: I have tried both the syntax for the prompt
column in ?prompt?
column in #prompt()#

Appreciate your quick response.

blom0344

  • Guest
Re: Prompt in FM for Query Studio
« Reply #1 on: 30 Mar 2009 10:28:26 am »
in (#promptmany('Add one or more values!')#)    ????

RudiHendrix

  • Guest
Re: Prompt in FM for Query Studio
« Reply #2 on: 28 Oct 2009 09:57:47 am »
Was this the answer to your question? I'm looking for the exact same thing, but it doesn't seem to work as expected. :(

Offline CognosPaul

  • Global Moderator
  • Statesman
  • *****
  • Join Date: Jan 2009
  • Posts: 1,912
  • Forum Citizenship: +268/-1
    • Paul's Cognos Blog
Re: Prompt in FM for Query Studio
« Reply #3 on: 28 Oct 2009 10:34:37 am »
In order to force Cognos to generate a value list for the user include a source column in the prompt macro.

prompt macro parameters:

prompt/promptmany
   (
   Parameter Name,
   Datatype,
   Default Value,
   Pretext,
   Source,
   PostText
   )

example:
Code: [Select]
#promptmany('Year','integer','year(getdate())','','[Sales].[Time].[Year]')#
« Last Edit: 29 Oct 2009 04:10:52 am by PaulM »

RudiHendrix

  • Guest
Re: Prompt in FM for Query Studio
« Reply #4 on: 28 Oct 2009 11:20:23 am »
This looks like exactly what I'm looking for. Unfortunately it doesn't work on my current model.

Let me tell you the steps that I'm taking...perhaps you can see where I am doing something wrong...which is obviously the case :)

First I create a query item
In the Expression definition I type:#promptmany('UOM','','','','[Database view].[T_DIM_TIME_YEAR].[YEAR] ')#

If I then try to test the QI I get a prompt screen of some kind. If I double click on the values I can create a list of values. If I enter only '2009' I get a result of all '2009'.
That's ok (and some result) but I would like to populate that list with results that a user can choose from.

If I enter two values I get an error message. Mentioning there is an error before or near position 8 of "'2010';" in parsing text '2010';'2009'

Offline CognosPaul

  • Global Moderator
  • Statesman
  • *****
  • Join Date: Jan 2009
  • Posts: 1,912
  • Forum Citizenship: +268/-1
    • Paul's Cognos Blog
Re: Prompt in FM for Query Studio
« Reply #5 on: 29 Oct 2009 04:13:22 am »
What is your filter exactly? Make sure it's set up correctly for a set instead of a single value.

RudiHendrix

  • Guest
Re: Prompt in FM for Query Studio
« Reply #6 on: 29 Oct 2009 04:30:35 am »
Euh...filter?  ???

I would like the user to select a single value out of a list of values. That selected value is the value I want to use in another QI. In that other QI I calculate the value that should be displayed based upon the selection that the user has made when he was prompted to do so.

Offline CognosPaul

  • Global Moderator
  • Statesman
  • *****
  • Join Date: Jan 2009
  • Posts: 1,912
  • Forum Citizenship: +268/-1
    • Paul's Cognos Blog
Re: Prompt in FM for Query Studio
« Reply #7 on: 29 Oct 2009 05:16:21 am »
A promptmany macro will return the results separated by a semicolon. SQL knows how to deal with separated values like that in a filter. For example:
Code: [Select]
[Year] in (#promptmany('UOM','','','','[Database view].[T_DIM_TIME_YEAR].[YEAR]')#)
You wouldn't put '2002';'2003';'2004';'2005' into a query item, but that is what the macro returns. In order to convert it into a string, you can use another macro function SQ.

For example:
Code: [Select]
case when #sq(promptmany('UOM','','','','[Database view].[T_DIM_TIME_YEAR].[YEAR]'))# contains '2005' then 'YES' else 'NO' end

RudiHendrix

  • Guest
Re: Prompt in FM for Query Studio
« Reply #8 on: 29 Oct 2009 05:49:20 am »
Ok...I feel I'm getting so close, that it would be a pitty to give up on this possibility.

I used the case statement to evaluate the chosen value and present a result.
Code: [Select]
CASE (#promptmany('UOM','','','','[Database view].[T_DIM_TIME_YEAR].[YEAR] ')#)
WHEN '2009' THEN '2009 is gekozen'
WHEN '2010' THEN '2010 is gekozen'
END

This works fine. If I type in 2009 it displays '2009 is gekozen' as result. If I type in 2010 it displays '2010 is gekozen' as result. This result (obviously in my actual package it will be a different value) can be used in another QI. Or my result in the QI can be more complex instead of this simple sentence. But this is basically what I'm looking for...

However there is still one thing missing: the user still needs to type the value himself. I was hoping that by referring to the '[Database view].[T_DIM_TIME_YEAR].[YEAR] ' a list with years would pop up. If there is another way (even hard coded) to provide the user a list of values to choose from I would really like to know it!

Thanks again!

Offline CognosPaul

  • Global Moderator
  • Statesman
  • *****
  • Join Date: Jan 2009
  • Posts: 1,912
  • Forum Citizenship: +268/-1
    • Paul's Cognos Blog
Re: Prompt in FM for Query Studio
« Reply #9 on: 29 Oct 2009 07:05:11 am »
Okay, the reason you're not seeing the list is because you're testing the query from within FM. When you publish the package, the list will be generated automatically.

The case statement is a bit problematic. Remember, when you select multiple values Cognos will return something like: '2009';'2010'. The case statement will fail for two reasons. First '2009';'2010' is not a string and cannot be parsed. Second, even if it was a string '2009;2010' that will never equal 2009 or 2010.

A better solution would be to put the prompt macro in the filter
Code: [Select]
[Database view].[T_DIM_TIME_YEAR].[YEAR] in (#promptmany('UOM','','','','[Database view].[T_DIM_TIME_YEAR].[YEAR] ')#) and change the case statement to

Code: [Select]
CASE [Database view].[T_DIM_TIME_YEAR].[YEAR]
WHEN '2009' THEN '2009 is gekozen'
WHEN '2010' THEN '2010 is gekozen'
END

RudiHendrix

  • Guest
Re: Prompt in FM for Query Studio
« Reply #10 on: 29 Oct 2009 08:21:54 am »
I tried to publish the package, but still no list is being generated. And I'm sure that the year dimension contains data.
There is no need for the user to select multiple values. The user should be prompted with a list and it is required that he picks one value. With that value I can  then create a case statement.

I think the solution that you are proposing does something like that. I'll give that a shot.

Now I'm using a table that is really part of the model and joined to the other tables (so the filter will also filter my facts), but in future I will have a separate filter to base my prompt and filter upon. Do you think that will work?

RudiHendrix

  • Guest
Re: Prompt in FM for Query Studio
« Reply #11 on: 29 Oct 2009 08:27:17 am »
Unfortunately still no list to select from in Query Studio. However....the filtering works. And the case statement also returns the correct value based upon my "selection".

Offline CognosPaul

  • Global Moderator
  • Statesman
  • *****
  • Join Date: Jan 2009
  • Posts: 1,912
  • Forum Citizenship: +268/-1
    • Paul's Cognos Blog
Re: Prompt in FM for Query Studio
« Reply #12 on: 29 Oct 2009 08:44:43 am »
It's very strange that the filter is not generating a list. Check the properties of [Database view].[T_DIM_TIME_YEAR].[YEAR]. If the Prompt Type is set to Edit Box, try changing it to Server Determined or Select Value.

If the users are only prompting for one value, change the prompt macro to prompt() instead of promptmany()

RudiHendrix

  • Guest
Re: Prompt in FM for Query Studio
« Reply #13 on: 29 Oct 2009 09:46:12 am »
Looks like I don't need to add the value. I only need to add the filter with the prompt in it.

So if I run it now....first I need to fill in (type) a value, then I get a drop down with only the value that I just typed.

I'm still a little bit at a loss... :(

Changed the promptmany() to prompt()
Removed the case statement (first it's useful to filter a complete dimension based upon a dropdown based upon a table)
Also changed the Prompt Type.

In all cases the result is as described above :(

Offline Blacksails

  • Full Member
  • ***
  • Join Date: Nov 2015
  • Posts: 19
  • Forum Citizenship: +0/-0
Re: Prompt in FM for Query Studio
« Reply #14 on: 15 Nov 2018 02:35:23 am »
Hello folks, i' m using the queryItem prperty of macros syntax  to obtain a list of values to request for filtering but i ve noticec that cognos reorder the values in the list in alphabetical order even if i ordered the item in a descending order.
IT is possible to force ordering or prevent cognos from ordering the values in the macro?