How to Create a Header Row with AsciiOutput

Header Row from AsciiOutput

Asciioutput is a great way to export data from TM1. The problem with it is that it does not automatically add a row at the top of the file with column headers. Here is a simple method to add a header line to a text file created by TM1 that can describe the data in columns below.

The column headings are useful for uploading into an external database with confidence that each column is what you expect and also can form the identifiers in a subsequent TI to reload the data into TM1.

Method to Create a Header Row in AsciiOutput

So how do I add a row of column headers into a text file created by TM1?  Pretty easily really.

On the Prolog tab I defined a variable, lets call it vHeader and made it equal to 1.

Then on the tab where you’re running the AsciiOutput, insert an IF statement and an additional AsciiOutput right before the AsciiOutput for the data.

Example of Putting a Header Line into a Text File Output from TM1

So something like this (note in this example I have defined variables for the path and filenames already):

If ( vHeader = 1);

AsciiOutput ( vPath | vFile, 'heading1', 'heading2', 'heading3'... 'headingN');

vHeader = vHeader + 1;

Endif;

AsciiOutput ( vPath | vFile, 'data1', 'data2', 'data3'... 'dataN');

What this does is set up the variable in the Prolog, then test if the variable equals 1. This will be true for the first record only. It then inserts into vFile and vPath the headings as defined. Then the variable is incremented by 1 so it will no longer satisfy the IF test. Finally, the regular AsciiOutput dumps out the data as requried.

If you like this post, please spread the love…

About John

Managing Director of Infocube. We are a management accounting consultancy that specialises in Business Analytics.

One comment on “How to Create a Header Row with AsciiOutput

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.