COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: niahanth on 06 Jan 2016 07:05:08 PM

Title: How to get previous months data based on the month selected in prompt window
Post by: niahanth on 06 Jan 2016 07:05:08 PM
I have a report in which i need to display results for the previous three months based on the month selected in prompt window. If user selects December the report should show data for November, October and September.
Title: Re: How to get previous months data based on the month selected in prompt window
Post by: Lynn on 07 Jan 2016 02:39:52 AM
Quote from: niahanth on 06 Jan 2016 07:05:08 PM
I have a report in which i need to display results for the previous three months based on the month selected in prompt window. If user selects December the report should show data for November, October and September.

I need to travel from Main Street to Maple Avenue. Can you give me directions? Probably not since I didn't mention what town I'm talking about. The directions could vary dramatically from one town to the next since those street names are very generic and could be found in many different towns.

Take a look at the forum etiquette post (http://www.cognoise.com/index.php/topic,24030.0.html) for information on how to provide specific information to get the best answers.

In your case it would help to know if you're using a relational or a dimensional package. You don't mention anything about the year. Will the user select from a list of months and separately identify the year or is it assumed to be something based on the month selection? Or will they be selecting from a date control?
Title: Re: How to get previous months data based on the month selected in prompt window
Post by: niahanth on 07 Jan 2016 06:47:48 AM
i have two prompmpths one for year and one for month based on that it need to select previous 3 months data. Its dimensional modelling
Title: Re: How to get previous months data based on the month selected in prompt window
Post by: MFGF on 07 Jan 2016 07:20:09 AM
Quote from: niahanth on 07 Jan 2016 06:47:48 AM
i have two prompmpths one for year and one for month based on that it need to select previous 3 months data. Its dimensional modelling

In that case, you probably need a query calculation in your report that uses the expression:

lastPeriods(3, prevMember([Your Month level from the Date hierarchy] -> ?Your Month parameter?))

MF.
Title: Re: How to get previous months data based on the month selected in prompt window
Post by: niahanth on 07 Jan 2016 07:33:03 AM
Thanks.. Can i use the same query for relational model??
Title: Re: How to get previous months data based on the month selected in prompt window
Post by: MFGF on 07 Jan 2016 08:01:00 AM
Quote from: niahanth on 07 Jan 2016 07:33:03 AM
Thanks.. Can i use the same query for relational model??

No.
Title: Re: How to get previous months data based on the month selected in prompt window
Post by: BigChris on 07 Jan 2016 08:09:03 AM
QuoteQuote from: niahanth on Today at 07:33:03 am
Thanks.. Can i use the same query for relational model??

No.

Beat me to it.  :D

Do you need to create a version for a relational model, or were you asking just out of interest?
Title: Re: How to get previous months data based on the month selected in prompt window
Post by: niahanth on 07 Jan 2016 08:19:31 AM
I have two models one is dimensional and one is relational that need reports to be created base on the month and year selected from the prompt. The data need to be displayed for previous three months. Can you tell me what sql query i need to use for relational model.

Thanks
Title: Re: How to get previous months data based on the month selected in prompt window
Post by: MFGF on 07 Jan 2016 08:38:32 AM
Quote from: niahanth on 07 Jan 2016 08:19:31 AM
I have two models one is dimensional and one is relational that need reports to be created base on the month and year selected from the prompt. The data need to be displayed for previous three months. Can you tell me what sql query i need to use for relational model.

Thanks

Why didn't you explain this when Lynn responded to you originally? It would have saved you a lot of time...

You don't need any SQL. Step away from the SQL dialog! :D

You haven't told us what format the values are you need to filter on. Are they dates? Months? If Months, are they numeric? Numbers but character strings? Month names? Something else? Without these kinds of details it's impossible to tell you how to code your filter expression. Lynn indicated you should include as much detail as possible in your question, but you don't seem to have heeded her advice...

MF.