COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: andoid95 on 22 May 2014 06:12:05 AM

Title: cumulative sum
Post by: andoid95 on 22 May 2014 06:12:05 AM
hello guys,

I have a relational PACKAGE and I want to calculate the sum of amounts from January until the month specified by user.
Ex: If the user selected  September 2013 so I have to give him the sum of amounts from 1 January 2013 to September 201

Thks
Title: Re: cumulative sum
Post by: MFGF on 22 May 2014 06:48:05 AM
Hi,

You could add a filter using the following approach for the expression:

[Your Date item] between _first_of_month (_add_months (?Your Date parameter?, 0 - (extract(month, ?Your Date parameter?) -1))) and ?Your Date parameter?

Cheers!

MF.
Title: Re: cumulative sum
Post by: andoid95 on 22 May 2014 07:03:46 AM
What do you mean about ?Your Date parameter? i just have ?year? and ?month? like parameter
Title: Re: cumulative sum
Post by: MFGF on 22 May 2014 07:07:28 AM
Quote from: andoid95 on 22 May 2014 07:03:46 AM
What do you mean about ?Your Date parameter? i just have ?year? and ?month? like parameter

Do you have a date in your data? If so, use this in the expression and a single date parameter (as in my suggestion) and you will get a single date prompt (appearing as a calendar)

If not, what format/data type is your month item? Is it a month number? What about year - is it numeric?

MF.
Title: Re: cumulative sum
Post by: andoid95 on 22 May 2014 07:18:22 AM
the date format I have is "March 23, 2005" and I can not extract the month in this format
is it exists a function that can convert this format in numeric ?
Title: Re: cumulative sum
Post by: MFGF on 22 May 2014 07:28:42 AM
Quote from: andoid95 on 22 May 2014 07:18:22 AM
the date format I have is "March 23, 2005" and I can not extract the month in this format
is it exists a function that can convert this format in numeric ?

So is this value a date field formatted to display as Month Day Year or is it a character field?

If (as I hope) it's the former, then use this item in the expression I gave you originally and it should work.

Cheers!

MF.
Title: Re: cumulative sum
Post by: andoid95 on 22 May 2014 07:33:34 AM
i have a GL date column (MMDDYYYY) i tried with it
Title: Re: cumulative sum
Post by: MFGF on 22 May 2014 07:46:46 AM
Quote from: andoid95 on 22 May 2014 07:33:34 AM
i have a GL date column (MMDDYYYY) i tried with it

Did it work? What was the result? Is it a date data type or a character field (or is it numeric MMDDYYYY)?

MF.
Title: Re: cumulative sum
Post by: andoid95 on 22 May 2014 08:09:37 AM
i complicated my life i just did [Relational Layer].[Period].[Fiscal period (YYYYMM)] between ?p_Year?|| '01' and ?p_Year?||?p_Month? and it works so !

thks a lot cause you have inspired me with the "betwwen"  8) ;) ;)