TI Process to filter subset on the basis of actual month
-
- Regular Participant
- Posts: 193
- Joined: Wed Apr 02, 2014 6:43 pm
- OLAP Product: TM1
- Version: 10.2
- Excel Version: 2010
TI Process to filter subset on the basis of actual month
Hello All
I would like to know about the TI Process, where i can filter month dimension subset-Forecast Month on the basis of actual month in control cube.
Suppose in my control cube, actual month is Jun - Now i want month dimension subset to filter all elements after may. (Jun to Dec should remain in subset)
I tried out as per following
Smonth=Cellgets('1f_admin','Actual Month','Version - Month View');
i=1;
while (i<13);
IF(i<DIMIX('1t_MONTHs',SMONTH));
SubsetElementDelete('1t_months','Forecastmonth',i);
Endif;
i=i+1;
End;
The result of process was (Feb,apr,jun,aug,oct,dec); It skip one element and delete one element. smonth=Jun and my expected result (May to dec)
What could be the reason affecting the result and is there better way to implement the process? May do it on the basis of attribute also?
Thanks
Dharav
I would like to know about the TI Process, where i can filter month dimension subset-Forecast Month on the basis of actual month in control cube.
Suppose in my control cube, actual month is Jun - Now i want month dimension subset to filter all elements after may. (Jun to Dec should remain in subset)
I tried out as per following
Smonth=Cellgets('1f_admin','Actual Month','Version - Month View');
i=1;
while (i<13);
IF(i<DIMIX('1t_MONTHs',SMONTH));
SubsetElementDelete('1t_months','Forecastmonth',i);
Endif;
i=i+1;
End;
The result of process was (Feb,apr,jun,aug,oct,dec); It skip one element and delete one element. smonth=Jun and my expected result (May to dec)
What could be the reason affecting the result and is there better way to implement the process? May do it on the basis of attribute also?
Thanks
Dharav
- jim wood
- Site Admin
- Posts: 3961
- Joined: Wed May 14, 2008 1:51 pm
- OLAP Product: TM1
- Version: PA 2.0.7
- Excel Version: Office 365
- Location: 37 East 18th Street New York
- Contact:
Re: TI Process to filter subset on the basis of actual month
You could create a control cube with 2 dimensions. One with the numbers 1-12, the other with a single text element. Then enter in to the cube:
1 Jan
2 Feb
etc...
Then if you set an attribute within the month dimension called month number, when you control cube has Jun in it. The attribute will be 6. You can then spool through the cube from 6 until the value is equal to 12, bringing back the relevant month from teh new cube.
I'm sure others will tell you another way of doing it as there are many but I thought this would be the easiest to comprehend,
Jim.
Edit: You could also use the next cube and attribute for next month calculations etc...
1 Jan
2 Feb
etc...
Then if you set an attribute within the month dimension called month number, when you control cube has Jun in it. The attribute will be 6. You can then spool through the cube from 6 until the value is equal to 12, bringing back the relevant month from teh new cube.
I'm sure others will tell you another way of doing it as there are many but I thought this would be the easiest to comprehend,
Jim.
Edit: You could also use the next cube and attribute for next month calculations etc...
Struggling through the quagmire of life to reach the other side of who knows where.
Go Build a PC
Jimbo PC Builds on YouTube
OS: Mac OS 11 PA Version: 2.0.7
Go Build a PC
Jimbo PC Builds on YouTube
OS: Mac OS 11 PA Version: 2.0.7
-
- Regular Participant
- Posts: 193
- Joined: Wed Apr 02, 2014 6:43 pm
- OLAP Product: TM1
- Version: 10.2
- Excel Version: 2010
Re: TI Process to filter subset on the basis of actual month
Jim
Could u give me small example on process to sloop after creating control cube with 2 dimensions? It would help me to understand the concept thoroughly?
Thanks
Dharav
Could u give me small example on process to sloop after creating control cube with 2 dimensions? It would help me to understand the concept thoroughly?
Thanks
Dharav
- jim wood
- Site Admin
- Posts: 3961
- Joined: Wed May 14, 2008 1:51 pm
- OLAP Product: TM1
- Version: PA 2.0.7
- Excel Version: Office 365
- Location: 37 East 18th Street New York
- Contact:
Re: TI Process to filter subset on the basis of actual month
I hope this helps...
This will give you Jun,Jul,Aug,Sep,Oct,Nov,Dec
Code: Select all
vCurrentMonth=CellGetS('Cube',dim,'Current Month); (june in this case)
vCurrentMonthNumber=AttrN(dim,vCurentMonth);
i=vCurrentMonthNumber;
Max=12;
while (i<=Max);
IF(i=vCurrwntMonthNumber);
vMonthText=vCurrentMonth;
Else;
vMonthText=vMonthText|','|CellGetS('Cube2',NumberToString(i),'Text');
EndIF;
i=i+1;
End;
Struggling through the quagmire of life to reach the other side of who knows where.
Go Build a PC
Jimbo PC Builds on YouTube
OS: Mac OS 11 PA Version: 2.0.7
Go Build a PC
Jimbo PC Builds on YouTube
OS: Mac OS 11 PA Version: 2.0.7
-
- Posts: 7
- Joined: Wed Jun 29, 2011 8:40 pm
- OLAP Product: TM1
- Version: 10.2.2
- Excel Version: 2010
Re: TI Process to filter subset on the basis of actual month
I would guess the reason your original code did not work is that the index order (you were looping thru DIMIX) did not reflect the natural month order. You have to be careful when relying on DIMIX to give you an expected sequence.
-
- Regular Participant
- Posts: 193
- Joined: Wed Apr 02, 2014 6:43 pm
- OLAP Product: TM1
- Version: 10.2
- Excel Version: 2010
Re: TI Process to filter subset on the basis of actual month
Thank you all. I would implement and let you know about the output.
Appreciate your input and valuable time.
Dharav
Appreciate your input and valuable time.
Dharav
-
- MVP
- Posts: 733
- Joined: Wed May 14, 2008 11:06 pm
Re: TI Process to filter subset on the basis of actual month
In a typical (for financial forecasting models) month dimension you will find Year-To-Go consolidations (YTG). Assuming a financial year runs Jan to Dec then an example would be:
- May YTG
---Jun
---Jul
---Aug
---Sep
---Oct
---Nov
---Dec
The May Year-To-Date (YTD) consolidation would include Jan through May meaning May YTD + May YTG = Full Year. YTG and YTD consolidations are very useful for a number of reporting purposes.
If you implement YTG consolidations in your month dimension then creating a 'future months' subset becomes simply a matter of adding the children of the current month's YTG consolidation. E.g.:
- May YTG
---Jun
---Jul
---Aug
---Sep
---Oct
---Nov
---Dec
The May Year-To-Date (YTD) consolidation would include Jan through May meaning May YTD + May YTG = Full Year. YTG and YTD consolidations are very useful for a number of reporting purposes.
If you implement YTG consolidations in your month dimension then creating a 'future months' subset becomes simply a matter of adding the children of the current month's YTG consolidation. E.g.:
Code: Select all
# initialise subset for forecast months
IF ( SubsetExists ( '1t_months', 'Forecastmonth' ) = 0 );
SubsetCreate ( '1t_months', 'Forecastmonth' );
ENDIF;
SubsetDeleteAllElements ( '1t_months', 'Forecastmonth' );
# get current month and YTG consolidation
sCurrentMonth=Cellgets('1f_admin','Actual Month','Version - Month View');
sCurrentMonthYTG = sCurrentMonth | ' YTG';
# iterate current month YTG consolidation for subset members
nCounter = 1;
nMaxCount = ELCOMPN ( '1t_months', sCurrentMonthYTG );
WHILE ( nCounter <= nMaxCount );
sChildMonth = ELCOMP ( '1t_months', sCurrentMonthYTG, nCounter );
SubsetElementInsert ( '1t_months', 'Forecastmonth', sChildMonth, nCounter );
nCounter = nCounter + 1;
END;
Robin Mackenzie
-
- Regular Participant
- Posts: 193
- Joined: Wed Apr 02, 2014 6:43 pm
- OLAP Product: TM1
- Version: 10.2
- Excel Version: 2010
Re: TI Process to filter subset on the basis of actual month
Hello All /Rmackenzie
Thank You all for your inputs.
I have implemented below process:
It works fine when i need < result but when i need > result than it throws the following error(Error: Prolog procedure line (20): Unable to insert element in subset. Position of element exceeds the number of elements in subset + 1 ). I know this error is because (See the highlighted in red color). Could you let me know, how to get the value of element position 1 and to increase thereafter? Instead of SubsetElementInsert if i use subsetdeleteelement than my purpose is getting resolvedbut every year we have to create subset manually for Jan to Dec.
IF ( SubsetExists ( '1t_months', 'Forecastmonth' ) = 0 );
SubsetCreate ( '1t_months', 'Forecastmonth' );
ENDIF;
SubsetDeleteAllElements ( '1t_months', 'Forecastmonth' );
#####################################################################
sCurrentMonth=Cellgets('1f_admin','Actual Month','Version - Month View');
#####################################################################
nCounter = 1;
nCount=Attrn('1t_months',sCurrentMonth,'Count');
nMaxCount = 12;
WHILE ( nCounter <= nMaxCount );
# sChildMonth = ELCOMP ( '1t_months', sCurrentMonthYTG, nCounter );
IF (nCounter>nCount);
sChildMonth = DimensionElementPrincipalName( '1t_Months', NumberToString(nCounter) );
SubsetElementInsert ( '1t_months', 'Forecastmonth', sChildMonth, ncounter );
Endif;
nCounter = nCounter + 1;
END;
##########################################################################
Thanks
Dharav
Thank You all for your inputs.
I have implemented below process:
It works fine when i need < result but when i need > result than it throws the following error(Error: Prolog procedure line (20): Unable to insert element in subset. Position of element exceeds the number of elements in subset + 1 ). I know this error is because (See the highlighted in red color). Could you let me know, how to get the value of element position 1 and to increase thereafter? Instead of SubsetElementInsert if i use subsetdeleteelement than my purpose is getting resolvedbut every year we have to create subset manually for Jan to Dec.
IF ( SubsetExists ( '1t_months', 'Forecastmonth' ) = 0 );
SubsetCreate ( '1t_months', 'Forecastmonth' );
ENDIF;
SubsetDeleteAllElements ( '1t_months', 'Forecastmonth' );
#####################################################################
sCurrentMonth=Cellgets('1f_admin','Actual Month','Version - Month View');
#####################################################################
nCounter = 1;
nCount=Attrn('1t_months',sCurrentMonth,'Count');
nMaxCount = 12;
WHILE ( nCounter <= nMaxCount );
# sChildMonth = ELCOMP ( '1t_months', sCurrentMonthYTG, nCounter );
IF (nCounter>nCount);
sChildMonth = DimensionElementPrincipalName( '1t_Months', NumberToString(nCounter) );
SubsetElementInsert ( '1t_months', 'Forecastmonth', sChildMonth, ncounter );
Endif;
nCounter = nCounter + 1;
END;
##########################################################################
Thanks
Dharav
-
- MVP
- Posts: 1831
- Joined: Mon Dec 05, 2011 11:51 am
- OLAP Product: Cognos TM1
- Version: PA2.0 and most of the old ones
- Excel Version: All of em
- Location: Manchester, United Kingdom
- Contact:
Re: TI Process to filter subset on the basis of actual month
The error you are getting is fairly obvious.
If the first element you find that fits your criteria is element 5, you are trying to insert it into your empty subset at position 5...
Replace it with 1 and every element will go in at position 1 forcing the other elements already in the subset further out. Or if you need it to be in specific order use subsetgetsize (...) +1
If the first element you find that fits your criteria is element 5, you are trying to insert it into your empty subset at position 5...
Replace it with 1 and every element will go in at position 1 forcing the other elements already in the subset further out. Or if you need it to be in specific order use subsetgetsize (...) +1
Declan Rodger
-
- MVP
- Posts: 1831
- Joined: Mon Dec 05, 2011 11:51 am
- OLAP Product: Cognos TM1
- Version: PA2.0 and most of the old ones
- Excel Version: All of em
- Location: Manchester, United Kingdom
- Contact:
Re: TI Process to filter subset on the basis of actual month
And on another note it would imo be cleaner to just use MDX.
Assuming I haven't put in any typos the MDX should give you something along the line of:
{FILTER({TM1SUBSETALL([month])}, [month].[monthno]>5)}
If you are to use it as part of a TI datasource it may be worth converting the subset back from dynamic to static afterwards by removing and re-adding the last element etc.
Code: Select all
sDimName = '1t_months';
sSubsetName = 'ForecastMonth';
sAttributeName = 'Count';
sCurrentMonth=Cellgets('1f_admin','Actual Month','Version - Month View');
nCurrentMonth = AttrN ( sDimName, sCurrentMonth, sAttributeName );
IF ( SubsetExists ( sDimName, sSubsetName ) = 1 );
SubsetDestroy ( sDimName, sSubsetName );
ENDIF;
sMDX = '{FILTER( {TM1SUBSETALL( [' | sDimName | '] )}, [' | sDimName | '].[' | sAttributeName |'] > ' | nCurrentMonth | ')}';
SubsetCreateByMDX ( sSubsetName, sMDX, sDimName );
Assuming I haven't put in any typos the MDX should give you something along the line of:
{FILTER({TM1SUBSETALL([month])}, [month].[monthno]>5)}
If you are to use it as part of a TI datasource it may be worth converting the subset back from dynamic to static afterwards by removing and re-adding the last element etc.
Declan Rodger
-
- Regular Participant
- Posts: 193
- Joined: Wed Apr 02, 2014 6:43 pm
- OLAP Product: TM1
- Version: 10.2
- Excel Version: 2010
Re: TI Process to filter subset on the basis of actual month
Declanr
!Bingo
Thank You for Input
!Bingo





Thank You for Input