I have two separate dimension for Months and Year. Months dimension have two attribute call MonthNo and MonthYear. I am using rule to populate which year it should be using to the MonthYear attribute. Eg now it is october, so Jan to Oct will be using 2012 sales data, and Nov-Dec will be using 2011 sales data.
I would like to get some feedback if there is any better way of doing this ?
Year Dimension
Structure
- 2011
- 2012
- Rolling 12 Months
Months Dimension
Attribute
- MonthNo
- MonthYear
Structure
-Jul
-Aug
-Sep
-Oct
-Nov
-Dec
-Jan
-Feb
-Mar
-Apr
-May
-Jun
Code: Select all
skipcheck;
['MonthYear'] =S: IF(ATTRN('Months', !Months, 'MonthNo') <= Month(Date(NOW)), TIMST(NOW, '\Y'), TIMST(DAYNO(Dates(TIMVL(NOW, 'Y') -1,1,1)), '\Y'));
Sales Cube
Code: Select all
skipcheck;
['Rolling 12 Months'] = N:DB('Sales Cube', !test - Customer, !Months, ATTRS('Months', !Months, 'MonthYear'), !test - Measures);
feeders;
['All Years'] => ['Rolling 12 Months'];