Showing posts with label Calender. Show all posts
Showing posts with label Calender. Show all posts

How to create a culturally specific calendar in Oracle BI

Despite globalisation, we still live in a multicultural world. It is very important to take this into account as some of the data to be analysed may be dependent on the period of the year it was generated. Not taking these outside factors into account could lead to wrong conclusions for an organisation and therefore bad decisions could be taken.
In this article we will see an example of how important it is to analyse the data based on its’ cultural environment and will present a technical solution to achieve that.

A Definition: Seasonality

We say that there is seasonality in data when the performance of an organisation in a business process is directly related to the period of time it happens. For instance, in western countries, during Christmas, retail sales increase considerably.
In other words, by analysing the data over a long period of time we can identify a changing behaviour in business processes in one or multiple periods of time across the years.

The Challenge

Due to globalisation, we may wrongly assume that the Gregorian calendar (months January → December) is the official and only calendar worldwide. This false assumption may lead to a false perception of reality when analysing data generated in another culture.
Worldwide multiple calendars are used by many cultures (ex. Gregorian, Hijrah, Japanese Imperial, Persian, Thai Buddha…). Our goal is to analyse data based on a calendar different from the Gregorian calendar.

The Scenario

Let’s take a look at the following chart:
ClearPeaks - Marketing - Blog - Create an Arabic Calendar in OBI - Image 1.v1.0
Figure 1: Sales analysis using the Gregorian Calendar
By analysing this chart, we can observe that sales in October, November and December are very irregular if we compare them to the sales throughout the rest of the months. However, this analysis is not leading us to any conclusion on the reasons behind this behaviour.
Now let’s take a look at the same chart, this time with some visual aid:
ClearPeaks - Marketing - Blog - Create an Arabic Calendar in OBI - Image 2.v1.0
Figure 2: Sales analysis using the Gregorian Calendar (low valued highlighted)

Now we can observe something very interesting: As years go by, the low values move from December to October progressively. What is driving this behaviour? Hint: This data is showing sales in an Arabic country.
In the Arabic culture the official calendar (Hijrah) consists of 354 or 355 days grouped in 12 lunar months. One of these months is called Ramadan. During this month, apart from fasting, people usually work less hours per day instead of the usual 8 hours.
Taking this into account, it is not unusual to see a decrease in the performance of some business processes such as sales.

The Solution

In order to show the appropriate information, we need to go through the following steps:
· Add the Hijrah Calendar columns to the Date dimension table
· Modify the OBI Repository to use these new columns
· Create a report using the new Hijrah calendar columns
· Add the Hijrah Calendar columns to the Date dimension table
· Modify the OBI Repository to use these new columns
· Create a report using the new Hijrah calendar columns

Add the Hijrah Calendar columns to the Date dimension table

We will start adding columns showing the Hijrah calendar information in the Date dimension table (Date_D).
For this purpose, we first need to alter the table to add the new columns:
Courrier 1
Next we need to populate these two columns with the appropriate values. This requires a two step process:
1. Modify the calendar in our database session
Courrier 2
Execute the following select statement to verify that the change is done:
Courrier 3
At this point our database will show dates based on the Hijrah calendar as you can see in the following query:
Courrier 4
2. Populate the new columns
Courrier 5
Don’t forget to commit your changes!
Courrier 6
After this change, we can revert the calendar session and check the data in the DATE_ID table:
Courrier 7
Modify the OBI Repository to use these new columns
The steps required by layer are:
· Physical Layer: Import the new physical columns
· Business Model & Mapping Layer: Create logical columns, create a new hierarchy in the Date dimension hierarchy
· Presentation Layer: Add the new presentation columns to a subject area
This is the final view of the repository based on the changes described above (only relevant parts are shown):
ClearPeaks - Marketing - Blog - Create an Arabic Calendar in OBI - Image 3.v1.0
Figure 3: Changes in the OBI Repository

Create a report using the new Hijrah calendar columns

At that point you can create a new request in OBI Answers using the new columns containing the Hijrah calendar information, now available in the subject area. The final result, as shown previously, highlights the seasonality of sales in Arabic culture.
ClearPeaks - Marketing - Blog - Create an Arabic Calendar in OBI - Image 4.v1.0
Figure 4: Sales analysis using the Hijrah Calendar (highlighting seasonality of sales)

Wrap up

Information is useless if its message is not conveyed properly. Analysing the information in its appropriate context is essential to that purpose. When analysing data from other cultures; consider the seasonality of the data when preparing your calendar. The success or failure of your BI project can be dependent on this adjustment.

In Between Calendar Control with Sliding dates


I would like to share how I use to implement sliding days and dynamic date range with in reports.

Problem: Many times we come across requirement to have recent orders or activities etc. Here recent may be 1 day or 1 week or 1 month depends on different users.

Solution: To accommodate all above, I will pull report with latest 7 days i.e
Between CURRENT_DATE-7 and CURRENT_DATE and also I will give controls to user to choose between dates from page prompt so that user can get what they need.

Example: Today(July 24) report will pull recent 7 days as default(July 17 to July 24) and if I access same report tomorrow , report will pull July 18 to July 25 data as default. Same time user provided with page prompt control to choose dates. (Exp. July 17 to July 30).
Here are step by step to do that.
At first we need to have dynamic variables so create Server Variable’s for your requirement in my case startDate_ServerVariable with week ago date (SYSDATE - 7) and endDate_ServerVariable as Current date (SYSDATE).
1. To do that, in RPD navigate to repository – initialization block
2. Create new initialization block
3. Edit Data Source
4. Select Data Source Type as Database
5. Edit default initialization string with “select sysdate, sysdate-7 from dual”
6. Assign Connection Pool and also choose refresh rate of these variables.
7. Click on test to see proper values populated and say okay
8. Now click on Edit Data Target button
9. Create server variables
10. Click okay; close Variable Manager, Save RPD.


Now create prompts with Date-Calendar control and assign default value with server variable and also create new presentation variables as shown below.
Create report with filter on date column using between syntax will be like,
DateColumn is between @{startDate_PVariable}{1900-01-01 12:00:00} and @{endDate_PVariable}{1900-01-01 12:00:00}

For more detailed information follow these articles.
Venkat posted very good article on between, John has posted very good solution on Calendar Control.

Possible error:
If you have not specified proper default values for presenation variables exp "Date”.CreatedDate" is between @{startDate_PVariable} and @{endDate_PVariable} then you will end up with following error.
Error getting drill information: SELECT "Date”.CreatedDate" saw_0 FROM subjectarea WHERE "Date”.CreatedDate" BETWEEN date '0000-00-00' AND date '0000-00-00'
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 46048] Datetime Month value 0 from 0000-00-00 is out of range. (HY000)

Make sure proper default value has provided for presentation variable.

--Next post on how to manage/switch between multiple environments on single machine