If users need capability to get back rolling 12 months of data based on one month selected in dashboard, the following code will do this:
"Month"."Month" between (CASE WHEN SUBSTRING('@{AsOfMonth}' FROM 8 FOR 2) = '12' THEN SUBSTRING('@{AsOfMonth}' FROM 1 FOR 4) ' / 01' ELSE SUBSTRING((CAST((CAST((SUBSTRING('@{AsOfMonth}' FROM 1 FOR 4) SUBSTRING ('@{AsOfMonth}' FROM 8 FOR 2)) AS INTEGER) - 99 ) AS CHAR(6))) FROM 1 FOR 4) ' / ' SUBSTRING((CAST((CAST((SUBSTRING('@{AsOfMonth}' FROM 1 FOR 4) SUBSTRING ('@{AsOfMonth}' FROM 8 FOR 2)) AS INTEGER) - 99 ) AS CHAR(6))) FROM 5 FOR 2) END) AND '@{AsOfMonth}'
This works if the month in database is in the format 'YYYY / MM'. I had earlier posted a way to do rolling 12 months based on date field in prompts and use TIMESTAMPDIFF function also. However that method has a disagvantage that it does not work with constrained prompts unless the date in database is exactly in the format of 'DD-MMM-YYYY'.
OBIEE Answers, Publisher, Installation, Configuration and work around tips. I record all issues and finding in oracle BI, that I can refer back later, or others can use for troubleshooting. I have extensive experience on OBIEE 10g version previously although currently I am on OBIEE 11g
Thursday, April 9, 2009
Going back 12 months based on selected month
Subscribe to:
Post Comments (Atom)
thanks for the post, it did solve my problem although the SQL that you have written is not for Oracle I hope.
ReplyDeleteThe SQL above is Oracle BI syntax, not for the Oracle database itself, if that was your question.
ReplyDeleteCAn you please provide the correct sysntax.I am getting View Display Error.
ReplyDeleteThanks,
Suresh.
What is the detailed error under view display error? Did you populate the variable @{AsOfMonth} in the dashboard properly?
Delete