When we perform financial analysis, we have to be able to easily adjust over which period we are going calculate each metric. For example, return on assets is net income divided by total assets. Net income is calculated over the past twelve months while total assets is an accumulated amount calculated over all previous months.
We can use set analysis to calculate these metrics at any one moment in time; however, we also would like to visualize the trend of these metrics. The best way to calculate that trend is to combine set analysis with an AsOfCalendar
.
An AsOfCalendar
contains the same months and years as a regular calendar. However, when we select a date in the AsOfCalendar
, we see everything that is prior to this data in the Facts
table. For example, in the following diagram if we select 2013-Jun in the AsOf Year-Month field, then we see all months prior to it in the data model as possible values in the Year-Month field:
We use a subroutine, Qvc.AsOfTable
in QV Components, to create the AsOfCalendar
and insert the following script after creating the MasterCalendar
table. We also add the AsOf Year
and AsOf Month
fields manually to make the table more useful. The table also contains a field called AsOf Months Ago
that tells us how many months difference there is between the AsOf Year-Month
and the Year-Month
. This field can be quite useful when we need to calculate rolling periods:
CALL Qvc.AsOfTable('Year-Month'); AsOfCalendar: Load *, Month([AsOf Year-Month]) as AsOfMonth, Year([AsOf Year-Month]) as AsOfYear Resident [AsOfTable_Year-Month]; Drop table [AsOfTable_Year-Month];
In order to take advantage of this calendar, we also need to replace the usual year and month filters with ones that use AsOf Year
and AsOf Month
. The filters will look exactly the same as the year and month filters in the sales perspective that uses the master calendar table. However, in the following sections, we see what changes we have to make to accurately calculate the expressions.
Let's start visualizing the financial perspective with the three most important reports.