Sunday 11 August 2013

Macro’s in Cognos Report Studio


The Cognos engine understands the presence of a macro as it is written within a pair of hashes (#). It executes the macros first and puts the result back into report specification like a literal string replacement. We can use this to alter data items, filters, and slicers at run time.
Here are some examples of macro functions:
1.       Prompt: [Country Name] = #prompt('Country')#.
·         Create a simple report which is having Country Name,Area Name,Project Desc and Francise columns.


·         Go to Query Explorer and open the query used by list.
·         Add a detail filter with following definition:
[Country Name] = #prompt('Country')#.
·         After running the report we can see a mandatory prompt for Country Name.
·         The report will output will be as follows


2.       PromptMany:[Area Name]  in (#promptmany('AreaName')#)

·         Create a simple report which is having Country Name,Area Name,Project Desc and Francise columns.
                  ·         Go to Query Explorer and open the query used by list.
·         Add a detail filter with following definition:
[Area Name]  in (#promptmany('AreaName')#)
                  ·         After running the report it will allow you to enter multiple values

5 comments:

  1. Can we use macro with parameter map?

    ReplyDelete
  2. Hi Terence,
    Can you provide one scenario as how to create a macro in parameter map

    ReplyDelete
    Replies
    1. Hi,

      Here is an example,

      #$pm_columns{ promptmany('Time Granularity','token','DY')}#

      where
      pm_columns is a parameter map name
      Time Granularity is the prompt name

      Thanks

      Delete