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
Showing posts with label ROLLING PERIOD. Show all posts
Showing posts with label ROLLING PERIOD. Show all posts
Thursday, April 9, 2009
Going back 12 months based on selected month
Subscribe to:
Comments (Atom)