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.
IF dosnt work with NUMBR
-
- 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
The first rule appears to be correct.
The second rule should be:
['Value'] = IF( ['First number'] = 4, 1, 0);
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
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
- 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
You have syntax issues there.
No, it doesn't. This would: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));
Code: Select all
['First number'] = S: SUBST ( !ALL.D.CENTRO_CUSTO_UNIDADE, 1, 1 );
And the above shouldn't even compile. This, however, should work:manoel.ss wrote:The second element brings "1" to 4 and "0" if it is not:
['Value'] = IF ('first number' = '4', 1, 0);
Code: Select all
['Value'] = IF ( ['First number'] @= '4', 1, 0 );
Kamil Arendt
-
- 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
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
['valor'] = N: IF(SUBST(!ALL.D.CENTRO_CUSTO_UNIDADE, 1, 1) @= '4', 1, 0);
That worked!
Manoel