Page 1 of 1

How to re-use the data from source twice?

Posted: Tue Oct 10, 2017 9:01 am
by Ashleigh W
Hi, I have set up data source in pro-log which is working as expected, now when it comes to data tab I want to be able to go through this data twice, this is because I want to process this condition for all true first and all false item in second time. I know we can create another ti process to process true first and false second, but we can eliminate this step if there is a way to loop though this source data twice.

please advice.
Thank you

Re: How to re-use the data from source twice?

Posted: Tue Oct 10, 2017 9:54 am
by qml
TM1 has a built-in mechanism to loop through the source data twice already - that's what the Metadata and Data tabs are for. And you can manipulate data on the Metadata tab - there are no rules against that.

Having said that, why can't you execute the condition separately for each record? I can't think of a common scenario where going through your data source more than once would be required for algorithmic reasons.

Re: How to re-use the data from source twice?

Posted: Tue Oct 10, 2017 12:12 pm
by ascheevel
I agree with qml that there might be a better solution that doesn't involve spinning through the datasource twice, but if you're set on it, you could always run the process twice and use a parameter and if statement to segregate operations between first and second run. You can call the second run from the epilog tab. The example code below assumes the process has a parameter called pRerun and the default value is set to zero.

Prolog tab:

Code: Select all

pRerun = pRerun + 1;
Data tab:

Code: Select all

IF(pRerun = 1);
#	do stuff here that you want to do on the first run for all true stuff
ELSEIF(pRerun = 2);
#	do stuff here that you want to do on the second run for all false stuff
ENDIF;
Epilog tab:

Code: Select all

# IF statement prevents process from calling itself ad infinitum
IF(pRerun = 1);
	ExecuteProcess('SomeProcess', 'pRerun',pRerun);
ENDIF;

Re: How to re-use the data from source twice?

Posted: Tue Oct 10, 2017 2:24 pm
by Ashleigh W
This is helpful. thank you for your help.