IF dosnt work with NUMBR

Post Reply
manoel.ss
Posts: 12
Joined: Fri Jan 13, 2017 5:02 pm
OLAP Product: Cognos TM1
Version: 10.2.2
Excel Version: 2013

IF dosnt work with NUMBR

Post by manoel.ss »

Hello.

I'm creating a cube with a cell that returns "1" when the first character of the cost center equals 4 and returns "0" when it is other than 4. And I'm having problems, though it's a simple rule. The "IF" Always returns "0", even when the value is true (4).

I am making a rule using two elements:
The "first number" element returns the first character of the cost center:
['First number'] = NUMBR (SUBST (! ALL.D.CENTRO_CUSTO_UNIDADE, 1,1));

The second element brings "1" to 4 and "0" if it is not:
['Value'] = IF ('first number' = '4', 1, 0);

Anyone can help me to understand what is worng?
Thanks.

Manoel.
Wim Gielis
MVP
Posts: 3240
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1, Jedox
Version: PAL 2.1.5
Excel Version: Microsoft 365
Location: Brussels, Belgium
Contact:

Re: IF dosnt work with NUMBR

Post by Wim Gielis »

The first rule appears to be correct.

The second rule should be:

['Value'] = IF( ['First number'] = 4, 1, 0);
Best regards,

Wim Gielis

IBM Champion 2024-2025
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
User avatar
qml
MVP
Posts: 1097
Joined: Mon Feb 01, 2010 1:01 pm
OLAP Product: TM1 / Planning Analytics
Version: 2.0.9 and all previous
Excel Version: 2007 - 2016
Location: London, UK, Europe

Re: IF dosnt work with NUMBR

Post by qml »

You have syntax issues there.
manoel.ss wrote:The "first number" element returns the first character of the cost center:
['First number'] = NUMBR (SUBST (! ALL.D.CENTRO_CUSTO_UNIDADE, 1,1));
No, it doesn't. This would:

Code: Select all

['First number'] = S: SUBST ( !ALL.D.CENTRO_CUSTO_UNIDADE, 1, 1 );
manoel.ss wrote:The second element brings "1" to 4 and "0" if it is not:
['Value'] = IF ('first number' = '4', 1, 0);
And the above shouldn't even compile. This, however, should work:

Code: Select all

['Value'] = IF ( ['First number'] @= '4', 1, 0 );
Kamil Arendt
manoel.ss
Posts: 12
Joined: Fri Jan 13, 2017 5:02 pm
OLAP Product: Cognos TM1
Version: 10.2.2
Excel Version: 2013

Re: IF dosnt work with NUMBR

Post by manoel.ss »

Thanks qml and Wim Gielis by the answers! Both help me to simplify my rule to:

['valor'] = N: IF(SUBST(!ALL.D.CENTRO_CUSTO_UNIDADE, 1, 1) @= '4', 1, 0);

That worked!

Manoel
Post Reply