A Coding Example of Computing Link Relative Ratio and Year-on-year Basis

Link relative ratio refers to comparison between the current data and data of the previous period. The interval is usually one month. For example, divide sales amount of April by that of March, and you get the link relative ratio of April. Hour, day, week and quarter can also be used as the time interval. Year-on-year comparison is the comparison between the current data and data of the corresponding period of the previous year. For example, divide sales amount of April 2014 by that of April 2013. In business, data of multiple periods is usually computed to find the variation trend. 

Seeking link relative ratio and year-on-year comparison is common inter-row and inter-group computations, which are easy to be performed with esProc. The following example is used to illustrate the computations. 

Case description:

To compute the link relative ratio and year-on-year comparison of each months sales amount within the designated period. The data comes from table order. Some of the data is shown below:

esProc code:

A1=esProc.query("select * from sales3 where OrderDate>=? and OrderDate<=?",begin,end)





Code interpretation:

A1: Query in the database according to periods. begin and end are external parameters. Such as, begin="2011-01-01 00:00:00"end="2014-07-08 00:00:00"(i.e. the date of today which can be obtained through now() function). Some of the query results are as follows: 

A2: Group orders by year and month, then summarize and seek each months sales amount. Some of the computed results are as follows: 

A3: Add a new field Irr, i.e, the link relative ratio on a month-on-month basis. The code is mAmount/mAmount[-1], in which mAmount represents sales amount of the current month, and mAmount[-1] represents that of the previous month. Note that the initial months link relative ratio is empty (i.e. January 2011). Computed results are: 

A4: Sort A3 by month and year to compute year-on-year comparison. Complete code should be: =A3.sort(m,y). Since A3 is originally sorted by the year, so we just need to sort by the month, the code is: A3.sort(m), which has a higher performance. Some of the computed results are:  

A5: Add a new field yoy, i.e., theyear-on-year comparison of monthly sales amount. The code is: if(m==m[-1],mAmount/mAmount[-1],null), meaning that the computation of year-on-year comparison is only performed over the corresponding months. Note that the year-on-year comparison for months of the initial year (i.e. the year 2011) is always. Some of the computed results are:  

A row of code, A6=A5.sort(y:-1,m), can be added to make observation easier. That is, sort A5 in descending year order and ascending month order. Note that the data comes to an end in July 2014. Results are shown below: 

Views: 582

Comment by Jim King on July 30, 2014 at 8:39pm

Compare the sales amount with the previous month, compare with the corresponding period of last year...in business analytics, such data comparison is quite necessary to find the business trends,how do you calculate them? And what do you think of the method illustrated above?


You need to be a member of Oracle Community to add comments!

Join Oracle Community

Oracle Community On

I'm not a fan of advertising, and so I will not be including any advertisements on OracleCommunity.net. However, managing this community does not come without cost! If you are willing to donate to help pay for the monthly community fees and domain services I accept Bitcoin and PayPal donations.

Donate Bitcoins



Blog Posts

Looking to Publish Scientific, Technical and Medical Articles? Take a look!

Digital publishers who are involved in publishing Scientific, Technical and Medical (STM) content follow a very rigorous routine of editing, formatting, and publishing. Primarily, the content is meticulously scanned for grammatical errors and logical inequalities. Then a final draft is made in adherence to the guidelines set by the publishing platform and forwarded to TO BE PUBLISHED’ folder. All articles, papers, and…


Posted by Alvaro Dee on October 21, 2016 at 3:29am

Apple Opens Its First iOS App Development Centre in Italy

Apple aims at making things rounder and sleeker. With iPhone 7 out in the field, Apple is now investing its time and resources in organizing workshops and opening new iOS app development centers to educate people in advanced methods of iOS app building.

Apple’s highlight of the year? It’s first-ever iOS development Centre in Naples!…


Posted by Alvaro Dee on October 20, 2016 at 12:33am

Outsource Your Data Conversion Services to Get an Edge over Your Competitors

The process of converting data from one standard format to any desired file format, Data conversion makes the data more precise, convenient, and retrievable, while keeping the core data unchanged. The precious asset to an organization, data helps in effective decision making if digitized, organized, and managed properly. Whereas the inefficient management of data makes it a burden on the business enterprise.

If the data is structured and digitized efficiently, it can help in achieving…


Posted by Alvaro Dee on October 19, 2016 at 5:54am

Data Mining Can Help Your Business Get a Competitive Edge

Data mining services are a vital part of business growth. Data mining, sometimes referred as knowledge discovery in databases, is the process of digging through data to discover hidden connections, patterns, and anomalies so that future trends can be predicted. The mined data can help businesses in cutting costs, increasing revenues, reducing risks, improving customer relationships, and more.

The diversity and volume of data that is being captured by companies today is staggering. The…


Posted by Alvaro Dee on September 29, 2016 at 2:17am

© 2016   Created by Steve Karam.   Powered by

Badges  |  Report an Issue  |  Terms of Service