COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: Raghuvir on 05 May 2014 08:21:16 AM

Title: Previous Week data when report executed on sysdate
Post by: Raghuvir on 05 May 2014 08:21:16 AM
hi all,

we have an requirement where we have to display data for previous week when the report is executed on the sysdate.

Could you guys help me to achieve this.

Thanks in advance.

Regards
Title: Previous Week data when report executed on sysdate
Post by: MFGF on 05 May 2014 09:25:39 AM
Quote from: Raghuvir on 05 May 2014 08:21:16 AM
hi all,

we have an requirement where we have to display data for previous week when the report is executed on the sysdate.

Could you guys help me to achieve this.

Thanks in advance.

Regards

The appropriate solution depends on whether you are using a relational or dimensional package. If you are using a dimensional package it would also help to know the structure of a MUN for a day member and a week member.

Cheers!

MF.


Sent from my iPad using Tapatalk HD
Title: Re: Previous Week data when report executed on sysdate
Post by: Raghuvir on 05 May 2014 10:29:51 AM
Hi MFGF,

We are using a relational package.

the requirement is, we are going to schedule the report to run on every monday. when it executes on monday it should be showing data for the previous week(monday to sunday)

could you guide us with the logic to be used.

Regards
Title: Re: Previous Week data when report executed on sysdate
Post by: Lynn on 05 May 2014 12:16:35 PM
Something similar to the below should work for a relational source. If you run on Monday this would be fine, but re-running it any other day of the week is going to give you the 7 days immediately preceding the current date. If you use the day of week function you can figure out what day it currently is and then adjust to always get the preceding Monday to Sunday range no matter what day you run it on. It is a little more complicated to do, but will ensure you can re-run if something fails on any given Monday.


[YourDate] between _add_days(current_date,-7) and _add_days(current_date,-1)
Title: Re: Previous Week data when report executed on sysdate
Post by: Raghuvir on 07 May 2014 01:55:59 AM
Quote from: Lynn on 05 May 2014 12:16:35 PM
Something similar to the below should work for a relational source. If you run on Monday this would be fine, but re-running it any other day of the week is going to give you the 7 days immediately preceding the current date. If you use the day of week function you can figure out what day it currently is and then adjust to always get the preceding Monday to Sunday range no matter what day you run it on. It is a little more complicated to do, but will ensure you can re-run if something fails on any given Monday.


[YourDate] between _add_days(current_date,-7) and _add_days(current_date,-1)



thanks Lynn... :)