COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: smtest on 09 Mar 2007 10:50:51 AM

Title: How to get the values for the previous day
Post by: smtest on 09 Mar 2007 10:50:51 AM
I have a crosstab in which i have few days in which there is no activity at all. So i want to put the previous day data(dates which has activities) in those days.
pls advice how i can do that.

example
thats what i have:
      2/1/2007   2/2/2007  2/3/2007  2/4/2007  2/5/2007
x      10                12          13                                       

what i want is
      2/1/2007   2/2/2007  2/3/2007  2/4/2007  2/5/2007
x      10                12          13               13            13


thanks                       
Title: Re: How to get the values for the previous day
Post by: kmuller on 21 Mar 2007 11:47:32 AM
Have you tried doing a add_days on the current date and subtracting 1?
Title: Re: How to get the values for the previous day
Post by: larsonr on 28 Apr 2007 08:39:18 PM
Try communicating this problem with your DBA.  It sounds like the data set is to only take in data when data exists.  They could during ETL solve this problem for you, and possibly add an extra column called repeated data.  That way you would know which is valid data and which was just repeated due to null data. 

Its just a thought.  I know as a best practice for us, we do a merge on the past 7 days with repolling data to catch up on errors at the source system or latent data getting to us.  In that scenario it would then overwrite your "repeated data" if new data was ever acquired for that day. 

Title: Re: How to get the values for the previous day
Post by: blom0344 on 02 May 2007 03:14:02 AM
You may solve this in the ETL process, depending on what you have in store.
If that does not solve it, you would need a stored procedure to process the data.
You would then loop through the dates and assign value of X to a variable. Use this variable value each time you run into a null value and reset it when running into the next 'real' value..
Title: Re: How to get the values for the previous day
Post by: MDXpressor on 20 May 2007 10:50:06 PM
Try creating an additional query.  In the second query, filter the date to the maximum date where 'x' is not null.  Have the caluclation for 'x' in the first query contain an if...then...else statement to go to the 2nd query if 'x' is null in the first.
Title: Re: How to get the values for the previous day
Post by: blom0344 on 21 May 2007 04:00:15 AM
Quote from: MDXpressor on 20 May 2007 10:50:06 PM
Try creating an additional query.  In the second query, filter the date to the maximum date where 'x' is not null.  Have the caluclation for 'x' in the first query contain an if...then...else statement to go to the 2nd query if 'x' is null in the first.

But what if there are multiple 'gaps' in the data? Or one gap that is not at the end of the range?
Title: Re: How to get the values for the previous day
Post by: MDXpressor on 21 May 2007 01:25:12 PM
Quote from: blom0344 on 21 May 2007 04:00:15 AM
But what if there are multiple 'gaps' in the data? Or one gap that is not at the end of the range?

You make a good point.  I was really only looking for the latest date which had a value.