COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: Sue on 31 Oct 2012 02:06:25 PM

Title: How to parse MUN value in cognos?
Post by: Sue on 31 Oct 2012 02:06:25 PM
Hello All,

The MUN looks something like the one below: [DWActivity].[AllDates].[AllDates].[Month]->:[PC].[@MEMBER].[20120901-20120930]
How to parse just [20120901-20120930]?  I need to build a report based on 2 different cubes. I don't have to combine the data but I use a value prompt(for Month Level). Is there a way I could use the parsed MUN in report filters? Please help

Thanks much!!
Title: Re: How to parse MUN value in cognos?
Post by: pricter on 31 Oct 2012 02:12:55 PM
If the muns of the two cubes are alike you can use a combination of macro
to change the mun.

More specifically you can use 'substitute' and 'prompt' macro.

which is the mun of the second cube?
Title: Re: How to parse MUN value in cognos?
Post by: Sue on 31 Oct 2012 02:32:24 PM
Thanks so much!! Yes the MUN is the same on the 2nd cube as well. Can you please help me with an example on how to use substitute in a prompt macro? I have tried but it did not work. Please advise.
Title: Re: How to parse MUN value in cognos?
Post by: pricter on 31 Oct 2012 03:06:48 PM
Unfortunately I do not have a package with two cubes in order to test it but I
imagine that the following could work

#substitute('DWActivity','DWActivity2',prompt('month','memberuniquename'))#

assuming that the MUN of the second cube is

[DWActivity2].[AllDates].[AllDates].[Month]->:[PC].[@MEMBER].[20120901-20120930]
Title: Re: How to parse MUN value in cognos?
Post by: Sue on 01 Nov 2012 12:11:23 PM
Thanks once again for your response!!
I am not able to get this to work! :(
Is this calc a slicer or dataitem or filter? Sorry I am new to MDX!
* I have a value prompt that displays month using month level from cube 1.
* Then I have a simple list report from cube 1 (this works)
* Then I bring in another list report from cube 2. How do I use the date filter from the value prompt in this query?
* Also I need to display YTD numbers based on the value prompt as well.

Please help!
Title: Re: How to parse MUN value in cognos?
Post by: pricter on 01 Nov 2012 12:17:16 PM
Which is the MUN of the second cube?

QuoteThen I bring in another list report from cube 2. How do I use the date filter from the value prompt in this query?
Use as data item

#substitute('DWActivity','DWActivity2',prompt('month','memberuniquename'))#

* Also I need to display YTD numbers based on the value prompt as well.

Use the periodsToDate ( level , member )
Returns a set of sibling members from the same level as "member", as constrained by "level". It locates the ancestor of "member" at "level" and returns that ancestor's descendants at the same level as "member" (up to and including "member"). Typically used with a time dimension. This function appears in the Rolling and Moving Averages interactive sample report.


Example: periodsToDate ( [great_outdoors_company].[Years].[Years].[Year] , [2004/Mar] )
Result: Returns values for [2004/Jan], [2004/Feb], [2004/Mar]
Title: Re: How to parse MUN value in cognos?
Post by: Sue on 01 Nov 2012 12:22:27 PM
Thanks so much!!!

[DWActivity].[AllDates].[AllDates].[Month]->:[PC].[@MEMBER].[20120901-20120930] - Cube1 MUN

[DWActivity2].[AllDates].[AllDates].[Month]->:[PC].[@MEMBER].[20120901-20120930] - Cube2 MUN

So in the code,  #substitute('DWActivity' ---> is this the month level that I have to use something like ([DWActivity].[AllDates].[AllDates].[Month])? Please advise.
Title: Re: How to parse MUN value in cognos?
Post by: pricter on 01 Nov 2012 12:32:01 PM
The
prompt('month','memberuniquename')
returns the MUN of the selected month
:
[DWActivity].[AllDates].[AllDates].[Month]->:[PC].[@MEMBER].[20120901-20120930]

and the substitute search the above for 'DWActivity' and replace it with the 'DWActivity2'

So as a results you will have
[DWActivity2].[AllDates].[AllDates].[Month]->:[PC].[@MEMBER].[20120901-20120930]

which is the MUN of the month for the second cube.

Title: Re: How to parse MUN value in cognos?
Post by: Sue on 01 Nov 2012 01:03:06 PM
Thank you !!! Thank you!! Truly appreciate your help !!