Rolling 12 Months with Description
Posted: Wed Nov 26, 2014 8:42 pm
Hi All,
I am new to TM1 and I am using TI process to create dimensions.
I am creating a time dimension with rolling 12 months. I am using the below logic to create it.
#************* ROLLING 12 FULL MONTHS **********************************************************************************************
sElement = 'Rolling 12 Full Months';
IF ( DIMIX ( sDateDim , sElement ) = 0 );
# create elements
DimensionElementInsert ( sDateDim , '' , sElement , 'N' );
DimensionElementComponentAdd ( sDateDim , sParent , sElement , 1 );
ENDIF;
# get last month - can get this from the "Last Month" element above
#get first month
IF ( nMonthLast = 12 );
nMonthFirst = 1;
nYearFirst = nYearLast;
ELSE;
nMonthFirst = nMonthLast + 1;
nYearFirst = nYearLast -1;
ENDIF;
nPeriodFirst = nYearFirst * 100 + nMonthFirst;
nPeriodLast = nYearLast * 100 + nMonthLast;
nPeriod = nPeriodFirst;
nMonth = nMonthFirst;
n = 1;
While ( n <= 12 );
#get month and add to element
sDate = STR( nPeriod , 6 , 0 );
IF (DIMIX( sDateDim , sDate) <> 0 );
sDate = DIMNM ( sDateDim , DIMIX ( sDateDim , sDate ) );
DimensionElementComponentAdd ( sDateDim , sElement , sDate , 1 );
else;
# exception!
ENDIF;
IF (nMonth = 12 );
# increment years as well
nPeriod = nPeriod + 89;
nMonth = 1;
ELSE;
nPeriod = nPeriod + 1;
nMonth = nMonth + 1;
ENDIF;
n = n + 1;
END;
Here my values are added like 201401 , 201402,201403 etcc....
Instead I want my values to be Jan 2014 , feb 2014..
How can I convert the string 201402 to feb 2014. Is the above approach right for creating this element,
Thanks,
Manu
I am new to TM1 and I am using TI process to create dimensions.
I am creating a time dimension with rolling 12 months. I am using the below logic to create it.
#************* ROLLING 12 FULL MONTHS **********************************************************************************************
sElement = 'Rolling 12 Full Months';
IF ( DIMIX ( sDateDim , sElement ) = 0 );
# create elements
DimensionElementInsert ( sDateDim , '' , sElement , 'N' );
DimensionElementComponentAdd ( sDateDim , sParent , sElement , 1 );
ENDIF;
# get last month - can get this from the "Last Month" element above
#get first month
IF ( nMonthLast = 12 );
nMonthFirst = 1;
nYearFirst = nYearLast;
ELSE;
nMonthFirst = nMonthLast + 1;
nYearFirst = nYearLast -1;
ENDIF;
nPeriodFirst = nYearFirst * 100 + nMonthFirst;
nPeriodLast = nYearLast * 100 + nMonthLast;
nPeriod = nPeriodFirst;
nMonth = nMonthFirst;
n = 1;
While ( n <= 12 );
#get month and add to element
sDate = STR( nPeriod , 6 , 0 );
IF (DIMIX( sDateDim , sDate) <> 0 );
sDate = DIMNM ( sDateDim , DIMIX ( sDateDim , sDate ) );
DimensionElementComponentAdd ( sDateDim , sElement , sDate , 1 );
else;
# exception!
ENDIF;
IF (nMonth = 12 );
# increment years as well
nPeriod = nPeriod + 89;
nMonth = 1;
ELSE;
nPeriod = nPeriod + 1;
nMonth = nMonth + 1;
ENDIF;
n = n + 1;
END;
Here my values are added like 201401 , 201402,201403 etcc....
Instead I want my values to be Jan 2014 , feb 2014..
How can I convert the string 201402 to feb 2014. Is the above approach right for creating this element,
Thanks,
Manu