Help: Asciioutput with Row Number

Post Reply
harrytm1
Regular Participant
Posts: 226
Joined: Thu Apr 02, 2009 2:51 pm
OLAP Product: IBM Planning Analytics
Version: Latest version
Excel Version: 2003 to 2019

Help: Asciioutput with Row Number

Post by harrytm1 »

Hi all,

I need to export a file from a cube so that another system can import the data. That system requires each row in the export file to have a unique record ID. Hence, I'm planning to concatenate the file serial number with a running number for each row to make up the Record ID.

FileSerialNo = '100';

So if the file contains 5 rows of records, Record ID for 1st row will be '1001' and for 5th and last row will be '1005'.

I don't think While loop will work in the Metadata script since each row is inserted after each pass through Metadata. How then do I create a running number?

Many thanks in advance!
Planning Analytics latest version, including Cloud
David Usherwood
Site Admin
Posts: 1458
Joined: Wed May 28, 2008 9:09 am

Re: Help: Asciioutput with Row Number

Post by David Usherwood »

Don't use the metadata tab.
In prolog:
counter = 0;

in data:
counter = counter +1;
asciioutput(
prefix | str(counter,4,0),
<rest of data>
);

The counter will increment each time the data tab is executed ie each time you have a record to output.
harrytm1
Regular Participant
Posts: 226
Joined: Thu Apr 02, 2009 2:51 pm
OLAP Product: IBM Planning Analytics
Version: Latest version
Excel Version: 2003 to 2019

Re: Help: Asciioutput with Row Number

Post by harrytm1 »

thanks for the quick reply, i'll give it a try.

Curious, does it mean i have to move all the scripts in Metadata tab to Data tab? What's the difference?
Planning Analytics latest version, including Cloud
David Usherwood
Site Admin
Posts: 1458
Joined: Wed May 28, 2008 9:09 am

Re: Help: Asciioutput with Row Number

Post by David Usherwood »

TI runs through the datasource once for metadata and again for data. The _idea_ is that you update dimensions in the metadata and content in data. (Note attributes are data, not metadata.)
I don't think putting export code in metadata rather than data will break anything, but I wouldn't see it as best practice. But make sure you don't leave anything behind in the metadata tab otherwise you'll pass through the data source twice.
harrytm1
Regular Participant
Posts: 226
Joined: Thu Apr 02, 2009 2:51 pm
OLAP Product: IBM Planning Analytics
Version: Latest version
Excel Version: 2003 to 2019

Re: Help: Asciioutput with Row Number

Post by harrytm1 »

thanks, David. The Ti is working now. Have a great day!
Planning Analytics latest version, including Cloud
Post Reply