COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: GuiCoRe on 11 Apr 2013 02:08:05 AM

Title: Calculation with prompt result
Post by: GuiCoRe on 11 Apr 2013 02:08:05 AM
Hello all (i'm back :)),

I'm still using TM1 Cube as source.

I have one question:
I have prompt with YearMonth : 201202,201203...

If the user choose 201202 I need to divide un column by 2, If the user choose 201306, I need to divide by 6 (Eg i need to divide by the month number)

But 201203 is not number.
The fact is that I can't get the month in number in order to divide the column.
Does it possible ? Could someone help me ?

Thank you so much,
Guicore
Title: Re: Calculation with prompt result
Post by: CognosPaul on 11 Apr 2013 03:32:47 AM
Is the user entering the value 201202 or is he selecting 201202 from a value prompt?

If he's selecting the member from a value prompt, and if your hierarchy is set up as Year --> Quarter --> Month (or Year --> Month) then you can try the following:

[Measure] / count(1 within set periodsToDate([Cube].[Time Dimension].[Time Hierarchy].[Year Level],#prompt('YearMonth','mun')#))

The user selects the month, the periodsToDate generates a set of all the months leading up to the selected month, which is counted with the count function. So if the user selects 201202, it will resolve as:

[Measure] / count(1 within set set(201201,201202))
[Measure] / 2
Title: Re: Calculation with prompt result
Post by: GuiCoRe on 11 Apr 2013 07:17:54 AM
Thank you Paul.

It works perfectly.

GuiCoRe