Hi,
I want to include a Gross Total row at the end of the CSV file after uploading all the records. I have written logic to get the gross total in Data Procedure.
I have a little problem in extracting data in a TI process. As you know, in a TI we can write the ASCIIOUTPUT function to write data from the cube into a csv file. But what happens is that when we open the same file in different tabs in the Advanced tabs, the files is opened as a fresh file. So when I write the data in the Data tab and at the same time, total the profit amounts, I need to write the final total of the profit amount in the same file as the last record. But I don’t know when the records will end so I am not able to decide when the Final total record has to be written. So I can write it in the Epilog tab. But then it cannot be done in the same file because if we open the same file then it will be opened as a fresh file and the original data will be lost.
Please suggest me how to do it. Thanks in advance.
Include Gross Total at the end of CSV file using TI Process
-
- Posts: 28
- Joined: Tue Jun 16, 2009 1:03 pm
- OLAP Product: IBM Cognos TM1
- Version: 9.5.1
- Excel Version: 2007
- Location: India
-
- Site Admin
- Posts: 6647
- Joined: Sun May 11, 2008 2:30 am
- OLAP Product: TM1
- Version: PA2.0.9.18 Classic NO PAW!
- Excel Version: 2013 and Office 365
- Location: Sydney, Australia
- Contact:
Re: Include Gross Total at the end of CSV file using TI Proc
One option to consider:pradeep.k.jagadeesan wrote:Hi,
I want to include a Gross Total row at the end of the CSV file after uploading all the records. I have written logic to get the gross total in Data Procedure.
I have a little problem in extracting data in a TI process. As you know, in a TI we can write the ASCIIOUTPUT function to write data from the cube into a csv file. But what happens is that when we open the same file in different tabs in the Advanced tabs, the files is opened as a fresh file. So when I write the data in the Data tab and at the same time, total the profit amounts, I need to write the final total of the profit amount in the same file as the last record. But I don’t know when the records will end so I am not able to decide when the Final total record has to be written. So I can write it in the Epilog tab. But then it cannot be done in the same file because if we open the same file then it will be opened as a fresh file and the original data will be lost.
Please suggest me how to do it. Thanks in advance.
- Write the output data as you're doing in the (presumably) Data tab;
- Write the total to another text file in the Epilog;
- Call a batch file which uses the DOS Copy command to merge the two files together.
"To them, equipment failure is terrifying. To me, it’s 'Tuesday.' "
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.
- Martin Ryan
- Site Admin
- Posts: 1989
- Joined: Sat May 10, 2008 9:08 am
- OLAP Product: TM1
- Version: 10.1
- Excel Version: 2010
- Location: Wellington, New Zealand
- Contact:
Re: Include Gross Total at the end of CSV file using TI Proc
Another option is to have a running total column in your csv file and update that as you go with every line.
You can keep a running total in the Data tab as it remembers what the variable was from the last loop through. In the prolog set runningTotal=0 then in the data tab set runningTotal=runningTotal+currentValue. Export that from the Data tab as your last column in the csv file.
Martin
You can keep a running total in the Data tab as it remembers what the variable was from the last loop through. In the prolog set runningTotal=0 then in the data tab set runningTotal=runningTotal+currentValue. Export that from the Data tab as your last column in the csv file.
Martin
Please do not send technical questions via private message or email. Post them in the forum where you'll probably get a faster reply, and everyone can benefit from the answers.
Jodi Ryan Family Lawyer
Jodi Ryan Family Lawyer
- Steve Rowe
- Site Admin
- Posts: 2456
- Joined: Wed May 14, 2008 4:25 pm
- OLAP Product: TM1
- Version: TM1 v6,v7,v8,v9,v10,v11+PAW
- Excel Version: Nearly all of them
Re: Include Gross Total at the end of CSV file using TI Proc
The only way I can see to do exactly this (in pure TM1) is to process the datasource twice. This is because you need to know how many records are in the source so you can output your total.
Prolog
ixMDLine=0;
ixDLine=0;
MetaData
ixLine=ixLine+1,
Data
#Near the top
ixDLine=ixDline+1;
#Near the end
If (ixDline=ixMDline);
#Your extra ascii output
endif;
Of course this will be slower to execute due to processing the source twice, so you will have to judge if it's worth the effort. Alan's approach wouold be faster but you'll need to google some DOS commands, it's probably not hard though.
Cheers
Prolog
ixMDLine=0;
ixDLine=0;
MetaData
ixLine=ixLine+1,
Data
#Near the top
ixDLine=ixDline+1;
#Near the end
If (ixDline=ixMDline);
#Your extra ascii output
endif;
Of course this will be slower to execute due to processing the source twice, so you will have to judge if it's worth the effort. Alan's approach wouold be faster but you'll need to google some DOS commands, it's probably not hard though.
Cheers
Technical Director
www.infocat.co.uk
www.infocat.co.uk