//Creates periods from January 2011 to August 2015
Periods:
LOAD
MonthName(AddMonths(MakeDate(Year(Today())-4),RecNo()-1)) as PERIOD
AutoGenerate 60-(12-Num(Month(Today())));
//Set minimum and maximum year
Temp_Periods:
LOAD
Min(Year(PERIOD)) as MinYear,
Max(Year(PERIOD)) as MaxYear
Resident Periods;
Let vMinYear = Peek('MinYear',0,'Temp_Periods');
Let vMaxYear = Peek('MaxYear',0,'Temp_Periods');
DROP Table Temp_Periods;
//Loop to create PERIODs and A.PERIODs from January 2011 to December 2015
//****Should be January 2011 to most recent Month & Year*****
For a = vMinYear to vMaxYear
For b = 1 to 12
For i = vMinYear to vMaxYear
For n = 1 to 12
A.Periods:
LOAD
Date(If($(a)=$(i), If($(b)<=$(n), MakeDate($(a), $(b)))),'MMM YYYY') as PERIOD,
Date(If($(i)=$(a), If($(n)>=$(b), MakeDate($(i), $(n)))),'MMM YYYY') as A.PERIOD
AutoGenerate(1);
Next
Next
Next
Next
|