Categories
- All Categories
- 15 Oracle Analytics Sharing Center
- 15 Oracle Analytics Lounge
- 208 Oracle Analytics News
- 41 Oracle Analytics Videos
- 15.7K Oracle Analytics Forums
- 6.1K Oracle Analytics Idea Labs
- Oracle Analytics User Groups
- 76 Oracle Analytics Trainings
- 14 Oracle Analytics Data Visualizations Challenge
- Find Partners
- For Partners
Run different filter in analysis dependent on day of week.

Hello,
I'm wondering if this can be achieved. I apologize in advance as I am a new user to OBIEE.
I'm automating a daily report that pulls previous day's data using field.dateopen = timestampadd(sql_tsi_day,-1,current_date).
I was hoping there would be a way I could, on Monday morning run a report that pulled field.dateopen is between timestampadd(sql_tsi_day,-3,current_date) and timestampadd(sql_tsi_day,-1,current_date). So when it ran Monday mornings it would pull data from Friday-Sunday.
Is there a way to build an if statement in the filter of an analysis to pull back this data? I was thinking of creating an if statement of "if dayofweek(current_date) = 2 then pull for the previous 3 days, else pull for yesterday.
I'm hoping to automate just one report as opposed to 2 separate reports that run these. Any help is appreciated.
Thanks!
Answers
-
Hi Mik,
Try the given formula in Advanced SQL filter. Logic is during Monday's we will subtract 4 from current_date and in the filter we use "greater than".
"Time"."Date" > CAST(CASE WHEN dayname(current_date)='Mon' THEN timestampadd(sql_tsi_day,-4,current_date) WHEN dayname(current_date)<>'Mon' THEN timestampadd(sql_tsi_day,-2,current_date) END AS DATE)
0 -
As Ebin posted your IF in SQL is a CASE WHEN (think at how would you make a SQL query managing that condition).
If you want to exclude current day values (in case they exists) adapt what Ebin gave you and change into a BETWEEN <the given formula> AND <your timestamp -1> and you get the same result.
I would just say to adapt a bit the CASE WHEN to remove the 2nd WHEN and make it a ELSE (if because or regional settings some users don't get days of week as "Mon" the provided code will just not work as it casts NULL to a date and so nothing come out). And as your WHEN and your ELSE returns dates (it's a timestampadd) no need to cast the CASE WHEN itself.
(optimizing your filter will be translated into a faster and smaller SQL filter)
0 -
Hi Ebin.
I am also a beginner user...
How would be the formula syntax if the filter vary betwenn two dates?
Thank You
0 -
Hi Eduardo,
You can use "BETWEEN" operator to display the values between 2 dates. The below mentioned example shows date between current_date -4 and current_date.
"Time"."Date" BETWEEN timestampadd(sql_tsi_day,-4,current_date) AND current_date
Or else add an "AND" condition to achieve the same.
"Time"."Date" >= timestampadd(sql_tsi_day,-4,current_date) and "Time"."Date"<= current_date
0 -
Hi Ebin.
I am also a beginner user...
How would be the formula syntax if the filter vary betwenn two dates?
Thank You
0