NumberToString / StringToNumber

Post Reply
mags88
Posts: 24
Joined: Wed Sep 14, 2011 11:59 pm
OLAP Product: TM1 Cognos
Version: 9.5.1
Excel Version: 2007

NumberToString / StringToNumber

Post 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
rmackenzie
MVP
Posts: 733
Joined: Wed May 14, 2008 11:06 pm

Re: NumberToString / StringToNumber

Post 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' );
Robin Mackenzie
mags88
Posts: 24
Joined: Wed Sep 14, 2011 11:59 pm
OLAP Product: TM1 Cognos
Version: 9.5.1
Excel Version: 2007

Re: NumberToString / StringToNumber

Post by mags88 »

Thank you
Post Reply