Tuesday, 24 April 2012

Switching Between Multiple Reports In Oracle BI 11g


Dashboard prompts are used for filtering data values in reports, but here is one more functionality of dashboard prompt that is, you can also use it to switch between multiple reports. I will show switching between reports without using any intermediate report. So I am using 3 reports which I want to switch using dashboard prompt which are Analysis A, Analysis B, and Analysis C. Here is an example along with the steps:



Ø  Step I: Create a Dashboard Prompt with the intended reports as a data value (Analysis A, Analysis B, and Analysis C) to be selected. 


1. Click on New->Dashboard Prompt->select any subject area.

Note: It will not affect on our dashboard prompt as we have to create presentation variable of our choice.

2. Definition Pane for dashboard prompt will open. Now select “Variable Prompt” as below.




3. Now “New Prompt” dialogue will open. Create presentation variable as PV,label it as Select Report  and select User Input as Choice List.




4. In Choice list Values click on plus (Green Icon) sign; it will display “Enter New Value” dialogue. Now manually enter the names of the reports which you want to display in prompt. Here I will put my three report names which I want to display as a list in dashboard prompt which are Analysis A, Analysis B, and Analysis C as below :




5. Now expand the Options. In “Default Selection” you can give any report name which you want to display by default on dashboard by selecting that report name as “Specific Custom Value”. Here I have given “Analysis A” as my default selection.




6. Now save your dashboard prompt. In this way our dashboard prompt is ready from selecting reports which will look like :




Ø  Step II: Create reports which you want to display according to selected report name in dashboard prompt.

Now I will create three reports named Analysis A, Analysis B, and Analysis C and will apply some filters in theses individual reports which will allow me to show the intended report as per selection made in dashboard prompt. So let’s create “Analysis A” 
 1.  I am taking some columns in reports plus one dummy column. I have change the column formula of Dummy column as:
CASE '@{PV}' WHEN 'Analysis A' THEN '1' ELSE '0' END

 
2. Now I have applied filter on Dummy Column as “is not equal to /is not in” ‘0’.
3. After changing column formula of Dummy Column and applying filter I have hide the dummy column by clicking on Column Properties > Column Format > Checked “Hide” checkbox. We can also delete the Dummy Column but make sure filter on that dummy column is important. Follow the same process in the rest two reports by slightly changing its column formula and filter based on the reports.
 
4. In “Analysis B” I have changed the column formula of Dummy Column and applied filter as :

CASE '@{PV}' WHEN 'Analysis B' THEN '1' ELSE '0' END

5. In “Analysis C” I have changed the column formula of Dummy Column and applied filter as:

CASE '@{PV}' WHEN 'Analysis C' THEN '1' ELSE '0' END




In this way we have done with creating all the three reports with intended filters.


Ø  Step 3: Putting dashboard prompt and three reports in Dashboard by applying certain conditions on each sections in “Edit Dashboard”.

1. In “Edit Dashboard” I am first putting dashboard prompt and then all the three reports as below:





Note: Put all the reports and dashboard prompt in separate sections as we have to apply the condition on section.

  

2. Now I am applying condition in section of “Analysis A”  by clicking on Properties > Condition > Section Condition as below :



3. For the section of “Analysis B” I am defining condition as: 



4. And finally for the section of “Analysis C” I am defining condition as: 



5. Now save your dashboard page and run it. 


6. Here “Analysis A“is my default report so it is visible on my dashboard by default. Now whatever options (report name) you will select from prompt those report will be shown. It is not necessary to show one default report; you can remove default selection from dashboard prompt. 

7. It will work as :







ENJOY





Monday, 16 April 2012

Various Calculations for Date


·        Due within Days:

TimestampDiff(SQL_TSI_DAY,CURRENT_DATE,"Time Dimension"."Date")



·        Days Past Due:

TimestampDiff(SQL_TSI_DAY, "Time Dimension"."Date",CURRENT_DATE)



·        Calculate current year with Current quarter:

EVALUATE ('TO_CHAR(%1,%2)' AS CHARACTER ( 30 ), CURRENT_DATE, 'YYYY-Q')



·        Calculate previous year’s Current Year with previous year’s current quarter:

EVALUATE ('TO_CHAR(%1,%2)' AS CHARACTER ( 30 ), TIMESTAMPADD( SQL_TSI_YEAR , -1, CURRENT_DATE), 'YYYY-Q')




·        Calculate current year with current fiscal quarter:

EVALUATE ('TO_CHAR(%1,%2)' AS CHARACTER ( 30 ), CURRENT_DATE, 'YYYY')||'-'||CAST("Time Dim"."Fiscal Quarter" AS char)


·        Calculate previous year’s current year with previous year’s current fiscal quarter:

EVALUATE ('TO_CHAR(%1,%2)' AS CHARACTER ( 30 ), TIMESTAMPADD( SQL_TSI_YEAR , -1, CURRENT_DATE), 'YYYY')||'-'||CAST("Time Dim"."Fiscal Quarter" AS char)



·        First Day of the CURRENT Month:

TIMESTAMPADD(SQL_TSI_DAY, -1,TIMESTAMPADD(SQL_TSI_MONTH,1,TIMESTAMPADD(SQL_TSI_DAY,1,TIMESTAMPADD(SQL_TSI_DAY, DAYOFMONTH(CURRENT_DATE)*-1, CURRENT_DATE))))

·        Last Day of Current Month

TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_MONTH , 1, TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE)))



·        First Day of the Previous Month

TIMESTAMPADD(SQL_TSI_MONTH, -1, TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE))


·        Last Day of the Previous Month

TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE))



·        First Day of the Next Month

TIMESTAMPADD(SQL_TSI_MONTH, 1, TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE))

·        Last Day of the Next Month

TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_MONTH , 2, TIMESTAMPADD( SQL_TSI_DAY , DAYOFMONTH( CURRENT_DATE) * -(1) + 1, CURRENT_DATE)))




·        First Day of the Current Year

TIMESTAMPADD( SQL_TSI_DAY , EXTRACT( DAY_OF_YEAR FROM CURRENT_DATE) * -(1) + 1, CURRENT_DATE)

·        Last Day of Current Year

TIMESTAMPADD(SQL_TSI_YEAR, 1, TIMESTAMPADD( SQL_TSI_DAY , -1, TIMESTAMPADD( SQL_TSI_DAY , EXTRACT( DAY_OF_YEAR FROM CURRENT_DATE) * -(1) + 1, CURRENT_DATE)))



·        First Day of the Previous Year

TIMESTAMPADD( SQL_TSI_YEAR , -1, TIMESTAMPADD( SQL_TSI_DAY , EXTRACT( DAY_OF_YEAR FROM CURRENT_DATE) * -(1) + 1, CURRENT_DATE))

·        Last Day of Previous Year

TIMESTAMPADD( SQL_TSI_DAY , -1, TIMESTAMPADD( SQL_TSI_DAY , EXTRACT( DAY_OF_YEAR FROM CURRENT_DATE) * -(1) + 1, CURRENT_DATE))


·        First Day of the Next Year

TIMESTAMPADD( SQL_TSI_YEAR , 1, TIMESTAMPADD( SQL_TSI_DAY , EXTRACT( DAY_OF_YEAR FROM CURRENT_DATE) * -(1) + 1, CURRENT_DATE))

·        Last Day of the Next Year

TIMESTAMPADD(SQL_TSI_YEAR, 2, TIMESTAMPADD( SQL_TSI_DAY , -1, TIMESTAMPADD( SQL_TSI_DAY , EXTRACT( DAY_OF_YEAR FROM CURRENT_DATE) * -(1) + 1, CURRENT_DATE)))



·        First Day of Current Quarter

TIMESTAMPADD( SQL_TSI_DAY , DAY_OF_QUARTER( CURRENT_DATE) * -(1) + 1, CURRENT_DATE)

·        Last Day of Current Quarter

TIMESTAMPADD( SQL_TSI_DAY , -(1), TIMESTAMPADD( SQL_TSI_QUARTER , 1, TIMESTAMPADD( SQL_TSI_DAY , DAY_OF_QUARTER( CURRENT_DATE) * -(1) + 1, CURRENT_DATE)))




·        Number of days between First Day of Year and Last Day of Current Month


DAYOFYEAR(CURRENT_DATE)






Friday, 13 April 2012

Calendar Date/Time Functions IN OBIEE


The calendar date/time functions manipulate data of the data types DATE and DATETIME based on a calendar year. You must select these functions together with another column; they cannot be selected alone.

Functions :

Current_Date
Current_Time
Current_TimeStamp
Day_Of_Quarter
DayName
DayOfMonth
DayOfWeek
DayOfYear
Hour
Minute
Month
Month_Of_Quarter
MonthName
Now
Quarter_Of_Year
Second
TimestampAdd
TimestampDiff
Week_Of_Quarter
Week_Of_Year
Year



Current_Date
Returns the current date. The date is determined by the system in which the Oracle BI Server is running.
Syntax
Current_Date

Current_Time
Returns the current time. The time is determined by the system in which the Oracle BI Server is running.
Note: The Analytics Server does not cache queries that contain this function.
Syntax
Current_Time(integer)
Where:
integer
Any integer that represents the number of digits of precision with which to display the fractional second.

Current_TimeStamp
Returns the current date/timestamp. The timestamp is determined by the system in which the Oracle BI Server is running.
Note: The Oracle BI Server does not cache queries that contain this function.
Syntax
Current_TimeStamp(integer)
Where:
integer
Any integer that represents the number of digits of precision with which to display the fractional second.

Day_of_Quarter
Returns a number (between 1 and 92) corresponding to the day of the quarter for the specified date.
Syntax
Day_Of_Quarter(dateExpr)
Where:
dateExpr
Any expression that evaluates to a date.

DayName
Returns the name of the day for a specified date.
Syntax
DayName(dateExpr)
Where:
dateExpr
Any expression that evaluates to a date.

DayOfMonth
Returns the number corresponding to the day of the month for a specified date.
Syntax
DayOfMonth(dateExpr)
Where:
dateExpr
Any expression that evaluates to a date.

DayOfWeek
Returns a number between 1 and 7 corresponding to the day of the week, Sunday through Saturday, for a specified date. For example, the number 1 corresponds to Sunday and the number 7 corresponds to Saturday.
Syntax
DayOfWeek(dateExpr)
Where:
dateExpr
Any expression that evaluates to a date.

DayOfYear
Returns the number (between 1 and 366) corresponding to the day of the year for a specified date.
Syntax
DayOfYear(dateExpr)
Where:
dateExpr
Any expression that evaluates to a date.

Hour
Returns the number (between 0 and 23) corresponding to the hour for a specified time. For example, 0 corresponds to 12 A.M. and 23 corresponds to 11 P.M.
Syntax
Hour(timeExpr)
Where:
timeExpr
Any expression that evaluates to a time.

Minute
Returns the number (between 0 and 59) corresponding to the minute for a specified time.
Syntax
Minute(timeExpr)
Where:
timeExpr
Any expression that evaluates to a time.

Month
Returns a number (between 1 and 12) corresponding to the month for a specified date.
Syntax
Month(dateExpr)
Where:
dateExpr
Any expression that evaluates to a date.

Month_Of_Quarter
Returns the number (between 1 and 3) corresponding to the month in the quarter for a specified date.
Syntax
Month_Of_Quarter(dateExpr)
Where:
dateExpr
Any expression that evaluates to a date.

MonthName
Returns the name of the month for a specified date.
Syntax
MonthName(dateExpr)
Where:
dateExpr
Any expression that evaluates to a date.

Now
Returns the current timestamp. This function is equivalent to the function current_timestamp .
Syntax
Now()

Quarter_Of_Year
Returns the number (between 1 and 4) corresponding to the quarter of the year for a specified date.
Syntax
Quarter_Of_Year(dateExpr)
Where:
dateExpr
Any expression that evaluates to a date.

Second
Returns the number (between 0 and 59) corresponding to the seconds for a specified time.
Syntax
Second(timeExpr)
Where:
timeExpr
Any expression that evaluates to a time.

TimestampAdd
Adds a specified number of intervals to a specified timestamp, and returns a single timestamp. Passing a null intExpr or timeExpr to this function results in the return of a null value.
In the simplest scenario, this function simply adds the specified integer value to the appropriate component of the timestamp, based on the interval. Adding a week translates to adding seven days, and adding a quarter translates to adding three months. A negative integer value results in a subtraction (such as going back in time).
An overflow of the specified component (for example, more than 60 seconds, 24 hours, twelve months, and so on) necessitates adding an appropriate amount to the next component. For example, when adding to the day component of a timestamp, this function makes sure that overflow takes into account the number of days in a particular month (including leap years). Similar measures are used to make sure that adding a month component results in the appropriate number of days for the day component (such as adding a month to '2010-05-31' does not result in '2010-06-31' because June does not have 31 days). The function also deals with the month and day components in a similar fashion when adding or subtracting year components.
Syntax
TimestampAdd(interval, intExpr, timestamp)
Where:
interval
The specified interval. Valid values are: SQL_TSI_SECOND, SQL_TSI_MINUTE, SQL_TSI_HOUR, SQL_TSI_DAY, SQL_TSI_WEEK, SQL_TSI_MONTH, SQL_TSI_QUARTER, SQL_TSI_YEAR.
intExpr
Any expression that evaluates to an integer value.
timestamp
Any valid timestamp.
Examples
Select {TimestampAdd(SQL_TSI_DAY, 3, TIMESTAMP'2000-02-27 14:30:00')}
From Employee where employeeid = 2;
In the above example, the query asks for the resulting timestamp when 3 days are added to '2000-02-27 14:30:00'. Since February, 2000 is a leap year, the query returns a single timestamp of '2000-03-01 14:30:00'.
Select {TimestampAdd(SQL_TSI_MONTH, 7, TIMESTAMP'1999-07-31 00:00:00')}
From Employee where employeeid = 2;
In the above example, the query asks for the resulting timestamp when 7 months are added to '1999-07-31 00:00:00'. The query returns a single timestamp of '2000-02-29 00:00:00'. Notice the reduction of day component to 29 because of the shorter month of February.
Select {TimestampAdd(SQL_TSI_MINUTE, 25, TIMESTAMP'2000-07-31 23:35:00')}
From Employee where employeeid = 2;
In the above example, the query asks for the resulting timestamp when 25 minutes are added to '2000-07-31 23:35:00'. The query returns a single timestamp of '2000-08-01 00:00:00'. Notice the propagation of overflow through the month component.

TimestampDiff
Returns the total number of specified intervals between two timestamps. Passing a null timestamp to this function results in a null return value.
This function first determines the timestamp component that corresponds to the specified interval parameter, and then looks at the higher order components of both timestamps to calculate the total number of intervals for each timestamp. For example, if the specified interval corresponds to the month component, the function calculates the total number of months for each timestamp by adding the month component and twelve times the year component. Then the function subtracts the first timestamp's total number of intervals from the second timestamp's total number of intervals.
The TimestampDiff function rounds up to the next integer whenever fractional intervals represent a crossing of an interval boundary. For example, the difference in years between '1999-12-31' and '2000-01-01' is 1 year because the fractional year represents a crossing from one year to the next (such as 1999 to 2000). By contrast, the difference between '1999-01-01' and '1999-12-31' is zero years because the fractional interval falls entirely within a particular year (such as 1999). Microsoft's SQL Server exhibits the same rounding behavior, but IBM's DB2 does not; it always rounds down. Oracle does not implement a generalized timestamp difference function.
When calculating the difference in weeks, the function calculates the difference in days and divides by seven before rounding. Additionally, the function takes into account how the administrator has configured the start of a new week in the NQSConfig.ini file. For example, with Sunday as the start of the week, the difference in weeks between '2000-07-06' (a Thursday) and '2000-07-10' (the following Monday) results in a value of 1 week. With Tuesday as the start of the week, however, the function would return zero weeks since the fractional interval falls entirely within a particular week. When calculating the difference in quarters, the function calculates the difference in months and divides by three before rounding.
Oracle BI Server pushes down the TIMESTAMPADD and TIMESTAMPDIFF functions to Microsoft's SQL Server and ODBC databases by default. While Oracle BI Server can also push to IBM's DB2, the features table is turned off by default due to DB2's simplistic semantics. (IBM's DB2 provides a generalized timestamp difference function, TIMESTAMPDIFF, but it simplifies the calculation by always assuming a 365-day year, 52-week year, and 30-day month.) The features table is also turned off by default for Oracle, since Oracle databases do not fully support these functions.
Syntax
TimestampDiff(interval, timestamp1, timestamp2)
Where:
interval
The specified interval. Valid values are: SQL_TSI_SECOND, SQL_TSI_MINUTE, SQL_TSI_HOUR, SQL_TSI_DAY, SQL_TSI_WEEK, SQL_TSI_MONTH, SQL_TSI_QUARTER, SQL_TSI_YEAR.
timestamp1
Any valid timestamp.
timestamp2
Any valid timestamp.
Examples
Select {TimestampDiff(SQL_TSI_DAY, TIMESTAMP'1998-07-31 23:35:00', TIMESTAMP'2000-04-01 14:24:00')}
From Employee where employeeid = 2;
In the above example, the query asks for a difference in days between timestamps '1998-07-31 23:35:00' and '2000-04-01 14:24:00'. It returns a value of 610. Notice that the leap year in 2000 results in an additional day.

Week_Of_Quarter
Returns a number (between 1 and 13) corresponding to the week of the quarter for the specified date.
Syntax
Week_Of_Quarter(dateExpr)
Where:
dateExpr
Any expression that evaluates to a date.

Week_Of_Year
Returns a number (between 1 and 53) corresponding to the week of the year for the specified date.
Syntax
Week_Of_Year(dateExpr)
Where:
dateExpr
Any expression that evaluates to a date.

Year
Returns the year for the specified date.
Syntax
Year(dateExpr)
Where:
dateExpr Any expression that evaluates to a date.