If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

How to get the values for the previous day

Started by smtest, 09 Mar 2007 10:50:51 AM

Previous topic - Next topic

smtest

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                       

kmuller

Have you tried doing a add_days on the current date and subtracting 1?

larsonr

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. 


blom0344

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..

MDXpressor

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.
No, a proof is a proof. What kind of a proof? It's a proof. A proof is a proof, and when you have a good proof, it's because it's proven.

-Jean Chretien

blom0344

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?

MDXpressor

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.
No, a proof is a proof. What kind of a proof? It's a proof. A proof is a proof, and when you have a good proof, it's because it's proven.

-Jean Chretien