Page 1 of 1

NumberToString / StringToNumber

Posted: Mon Sep 19, 2011 7:03 am
by mags88
Hi,

I understand the NumberToString / StringToNumber T.I. functions.

Is there a way to do a NumberToString / StringToNumber function within the cube rules (and not using the T.I.).

The reason for this is because I wish to be able to compare a number that is stored as a string to a number that is stored as a number using a IF TEST.

The following is a basic example.

e.g.

Code: Select all

['String'] = S: '123';
['Number'] = N: 123;
['Compare'] = IF(['String'] = ['Number'], 1, 0); 
This example results in an error because you cannot compare a string and a number. Is there a way to convert ['String'] to a number (or ['Number'] to a string) before doing the IF TEST. I do not want to run a T.I. process every time a user wants to compare two records.

Regards,
Magnus

Re: NumberToString / StringToNumber

Posted: Mon Sep 19, 2011 7:11 am
by rmackenzie
NUMBR will convert a string to a number and STR will convert a number to a string. You can use NUMBR and STR in TI, but you can't use NumberToString and StringToNumber in Rules.

E.g.

Code: Select all

['String'] = S: STR ( 1234.45, 4, 2 );
['Number'] = N: NUMBR ( '987' );

Re: NumberToString / StringToNumber

Posted: Mon Sep 19, 2011 8:05 am
by mags88
Thank you