Hi everyone,
This is my first time using this forum and also my first time writing any TI script. Below is the script I created to export data from a view to a txt file. I got that part down but the issue I am having is that my time parameter is not working, e.g when I pick sometime, my export file still shows ALL months.
This is my script:
#****Begin: Generated Statements***
#****End: Generated Statements****
#This TI Process copies FXRateInput_USD view data and exports it to a CSV file for Reporting to pick up
vCube = 'FX_Rates';
vDim1 = 'SCENARIO';
vDim2 = 'TIME';
vDim3 = 'FX_RATE_TYPE';
vDim4 = 'CURRENCY';
vDim5 = 'CURRENCY_2';
#FXOutPut = CellGetS('D:\TM1\Exports\FXRates\FXRates_Export.txt');
vView = '}FX_Rates_Export_JN';
vSub = '}FX_Rates_Export_JN';
If(ViewExists(vCube, vView) = 1);
ViewDestroy(VCube, vView);
EndIf;
ViewCreate(vCube, vView);
#########Create Scenario Subset
ExecuteProcess('SYSTEM_GenericSubsetCreator', 'pSubName',
vSub, 'pDimension',vDim1, 'pBasis', 'LEAF', 'pElement', pSrcScenario, 'pOverwrite', 'Yes');
#########Create Time
vTimeEl = ATTRS(vDim2, pStartMonth, 'Period');
WHILE(vTimeEl@<>ATTRS(vDim2, pEndMonth, 'Period'));
SubsetElementInsert(vDim2, vSub, vTimeEl, 1);
vTimeEl = ATTRS(vDim2, vTimeEl, 'Next Period');
END;
SubsetElementInsert(vDim2, vSub, vTimeEl, 1);
#########Create Currency Subset
ExecuteProcess('SYSTEM_GenericSubsetCreator', 'pSubName',
vSub, 'pDimension',vDim3, 'pBasis', 'LEVEL', 'pLevel', 0,'pOverwrite', 'Yes');
#########Create To Currency Subset
ExecuteProcess('SYSTEM_GenericSubsetCreator', 'pSubName',
vSub, 'pDimension',vDim4, 'pBasis', 'LEVEL', 'pLevel', 0,'pOverwrite', 'Yes');
#########Create Rate Type Subset
ExecuteProcess('SYSTEM_GenericSubsetCreator', 'pSubName',
vSub, 'pDimension',vDim5, 'pBasis', 'LEVEL', 'pLevel', 0,'pOverwrite', 'Yes');
#########Assign Subsets To View
ViewSubsetAssign(vCube, vView, 'Scenario', vSub);
ViewSubsetAssign(vCube, vView, 'Time', vSub);
ViewSubsetAssign(vCube, vView, 'Currency', vSub);
ViewSubsetAssign(vCube, vView, 'Currency_2', vSub);
ViewSubsetAssign(vCube, vView, 'FX_Rate_Type', vSub);
#########Assign Positions of Subsets In View
ViewColumnDimensionSet(vCube, vView, 'Scenario', 1);
ViewColumnDimensionSet(vCube, vView, 'Time', 2);
ViewRowDimensionSet(vCube, vView, 'Currency_2', 1);
ViewRowDimensionSet(vCube, vView, 'FX_Rate_Type', 2);
ViewTitleDimensionSet(vCube, vView, 'Currency');
#########Set View Parameters
ViewExtractSkipZeroesSet(vCube, vView, 0);
ViewExtractSkipCalcsSet(vCube, vView, 1);
ViewExtractSkipRuleValuesSet(vCube, vView, 0);
#########Set Datasource
DatasourceNameForServer = vCube;
DatasourceType = 'VIEW';
DatasourceCubeview = vView;
Creating parameter for time subset
-
- Posts: 1
- Joined: Wed Sep 26, 2012 10:46 pm
- OLAP Product: OFA
- Version: 10.1
- Excel Version: 2010
Creating parameter for time subset
Last edited by Alan Kirk on Tue Oct 09, 2012 7:52 pm, edited 1 time in total.
Reason: Moved to the correct forum. Useful tips (etc) is for OFFERING tips, not asking for them.
Reason: Moved to the correct forum. Useful tips (etc) is for OFFERING tips, not asking for them.
-
- Community Contributor
- Posts: 147
- Joined: Mon Nov 29, 2010 6:30 pm
- OLAP Product: Cognos TM1
- Version: 10.1
- Excel Version: Office 2010
Re: Creating parameter for time subset
Hi there,
Welcome to the forum and good on you for getting stuck into TI.
Are you trying to add all the time periods between the start and end point? If so, you're better off using a numeric attribute and doing an ATTRN comparison, rather than the string comparison. If you're just trying to add a single period, you can probably dispense with the WHILE statement.
Either way, I think your problem is with this part of your code;
You need to use the WHILE statement to scan through the elements in the dimension - TI doesn't know that you want to loop through this dimension unless you instruct it to.
In TM1 TI the syntax for what you are trying to do here should be closer to this;
EDIT: Slight change to code syntax.
Welcome to the forum and good on you for getting stuck into TI.
Are you trying to add all the time periods between the start and end point? If so, you're better off using a numeric attribute and doing an ATTRN comparison, rather than the string comparison. If you're just trying to add a single period, you can probably dispense with the WHILE statement.
Either way, I think your problem is with this part of your code;
Code: Select all
vTimeEl = ATTRS(vDim2, pStartMonth, 'Period');
WHILE(vTimeEl@<>ATTRS(vDim2, pEndMonth, 'Period'));
SubsetElementInsert(vDim2, vSub, vTimeEl, 1);
vTimeEl = ATTRS(vDim2, vTimeEl, 'Next Period');
END;
In TM1 TI the syntax for what you are trying to do here should be closer to this;
Code: Select all
iLimit = DimSiz( Dimension );
iIndex = 1;
WHILE( iIndex <= iLimit );
IF ( TEST );
ACTION IF TEST IS TRUE;
ENDIF;
iIndex = iIndex + 1;
END;