COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: mbrassfi on 21 Jan 2010 12:46:58 PM

Title: Same query for 2 years
Post by: mbrassfi on 21 Jan 2010 12:46:58 PM
Can you have 2 years of information in one query, or do you have to do two seperate queries and then join them?

Title: Re: Same query for 2 years
Post by: blom0344 on 22 Jan 2010 03:48:58 AM
 ???

There is no such restriction. However in the case you have seperate tables that contain data for each year you may need to build a union. However, I suspect you are asking this for a more specific reason.
So, please elaborate  ;D
Title: Re: Same query for 2 years
Post by: mbrassfi on 22 Jan 2010 08:56:19 AM
Well, how I was taught from my predecessor was if I wanted to show two years for the same attribute I needed to have two queries, one for the current year, and one for the previous year.  This seems quite arduous, and I feel that I should be able to create a data item that somehow says "Current Year to date actual" and another item that says "Prior year to date actual." I figure that if I can easily do that in any other system why not this?

All numbers that I want to pull are on the same table. 
Title: Re: Same query for 2 years
Post by: MFGF on 22 Jan 2010 09:23:09 AM
Hi,

If you are retrieving your Current Year/Previous Year by using filters, could you simply code a filter that retrieves both (ie OR the two filters together) and retrieve the two periods in the same query?

MF.