This is a guest post from Revelwood’s Jay Apwah.
Did you know that there are reserved local variables that you can use in TurboIntegrator scripts?
Reserved local variables are variables that do not need to be defined and are destroyed when the process finishes executing. This blog will describe three variables: Value_is_String, nValue, and sValue. You will not find these on the variables tab and you cannot re-define them, but they are accessible. These three variables can be accessed within the Metadata or Data tabs of TurboIntegrator.
This local variable can be used to test if the value of the data source cube view record that is currently being processed is a number. Value_is_String returns 0 (zero) if the value is a number. Otherwise, the value is a string.
NValue and SValue
In the variables tab of a standard TurboIntegrator process, you can define each variable as numeric or string. With this approach, however, you must set the variable type of the value to string. This is shown in variable #7 of the image below:
In this example, assume the source view contains string and numeric measures. Rather than creating separate views that contain only numeric values or only string values, you can check to see if each value is a string or number. Line 7 in the image below shows an example of the check. Lines 8 and 10 show the appropriate functions and reserved variables to use. Note the distinction between sValue and nValue.
In the variables tab, it was ok to set the variable type as string because TM1 knows that “sValue” means string and “nValue” means numeric and will therefore perform any required conversions.
As you can see, you can utilize the Value_is_String, nValue, and sValue local variables described above to create a more compact, efficient and less error-prone approach.
IBM Planning Analytics is full of new features and functionality. Not sure where to start? Our team here at Revelwood can help. Contact us for more information at firstname.lastname@example.org. And stay tuned for more Planning Analytics Tips & Tricks weekly in our Knowledge Center and in upcoming newsletters!