Hi Gurus,
I am stumped on a simple if condition which fails miserably. I am reading data from a csv file.
The first condition to check for blank works and fails checking 'N/A', <>0 and ='N'.
Can someone tell me where I am going wrong?
the condition translates to
if Proj_code is not blank or proj_code is not equal to 'N/A' or Proj_code is not equal '0' or if NewBuss is equal to 'N'
if ( Proj_code @<> '' % Proj_code @<> 'N/A' % Proj_code @<> '0' % NewBuss @= 'N') ;
-----
EndIf;
I have verified that the data is 'N/A', '0'. Dont understand why the OR condition fails. Can someone please help?
Thanks,
Paul.
Stuck on a if Condition.. too silly
-
- Posts: 80
- Joined: Tue Jun 04, 2013 3:35 pm
- OLAP Product: TM1
- Version: 10.2.2
- Excel Version: 2010
- Michel Zijlema
- Site Admin
- Posts: 712
- Joined: Wed May 14, 2008 5:22 am
- OLAP Product: TM1, PALO
- Version: both 2.5 and higher
- Excel Version: 2003-2007-2010
- Location: Netherlands
- Contact:
Re: Stuck on a if Condition.. too silly
So you're saying the data is 'N/A', '0' and you're checking on is not equal to 'N/A' or is not equal to '0'.LutherPaul wrote:the condition translates to
if Proj_code is not blank or proj_code is not equal to 'N/A' or Proj_code is not equal '0' or if NewBuss is equal to 'N'
if ( Proj_code @<> '' % Proj_code @<> 'N/A' % Proj_code @<> '0' % NewBuss @= 'N') ;
-----
EndIf;
I have verified that the data is 'N/A', '0'.
Isn't that your issue? Otherwise you need to be a bit more clear on what you expect to happen inside and outside of the if statement.
Michel
-
- Posts: 80
- Joined: Tue Jun 04, 2013 3:35 pm
- OLAP Product: TM1
- Version: 10.2.2
- Excel Version: 2010
Re: Stuck on a if Condition.. too silly
Thanks Michel for replying.
I have bad data coming in with values like 'N/A', '0', 'ASDF', which I want to avoid.
When the data is not in ('N/A', '0', 'ASDF'), I want my if to work else, nothing.
Hope I am clear.
Thanks,
Paul.
I have bad data coming in with values like 'N/A', '0', 'ASDF', which I want to avoid.
When the data is not in ('N/A', '0', 'ASDF'), I want my if to work else, nothing.
Hope I am clear.
Thanks,
Paul.
- gtonkin
- MVP
- Posts: 1211
- Joined: Thu May 06, 2010 3:03 pm
- OLAP Product: TM1
- Version: Latest and greatest
- Excel Version: Office 365 64-bit
- Location: JHB, South Africa
- Contact:
Re: Stuck on a if Condition.. too silly
As Michel said, you need ANDs , not ORs i.e. not blank and not N/A and not 0 etc.
-
- MVP
- Posts: 1817
- Joined: Mon Dec 05, 2011 11:51 am
- OLAP Product: Cognos TM1
- Version: PA2.0 and most of the old ones
- Excel Version: All of em
- Location: Manchester, United Kingdom
- Contact:
Re: Stuck on a if Condition.. too silly
Code: Select all
if ( Proj_code @<> '' % Proj_code @<> 'N/A' % Proj_code @<> '0' % NewBuss @= 'N') ;
Its sometimes easier to say if something is equal to such and such then itemskip.
Declan Rodger
-
- MVP
- Posts: 3128
- Joined: Mon Dec 29, 2008 6:26 pm
- OLAP Product: TM1, Jedox
- Version: PAL 2.0.9.18
- Excel Version: Microsoft 365
- Location: Brussels, Belgium
- Contact:
Re: Stuck on a if Condition.. too silly
True. In Metadata and Data tabs with more than a handful lines of code, I tend to use Itemskip and Itemreject first.declanr wrote:With code like this you are sort of applying a double negative... if the project code is "N/A" it can't also be blank so by using an or on it; the "N/A" gets through as it is not blank or 0.Code: Select all
if ( Proj_code @<> '' % Proj_code @<> 'N/A' % Proj_code @<> '0' % NewBuss @= 'N') ;
Its sometimes easier to say if something is equal to such and such then itemskip.
All other cases that remain will be treated with the remaining code.
Best regards,
Wim Gielis
IBM Champion 2024
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
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
- Michel Zijlema
- Site Admin
- Posts: 712
- Joined: Wed May 14, 2008 5:22 am
- OLAP Product: TM1, PALO
- Version: both 2.5 and higher
- Excel Version: 2003-2007-2010
- Location: Netherlands
- Contact:
Re: Stuck on a if Condition.. too silly
I second that. To me it was not clear whether the If statement enclosed an ItemSkip or the actionable code...declanr wrote:Its sometimes easier to say if something is equal to such and such then itemskip.
I would reverse the conditions and put an ItemSkip inside the if and the actionable code after the endif.
Otherwise (the actionable code still within the if) the condition should I assume be:
Code: Select all
if ( (Proj_code @<> '' & Proj_code @<> 'N/A' & Proj_code @<> '0') % NewBuss @= 'N') ;
-
- Posts: 80
- Joined: Tue Jun 04, 2013 3:35 pm
- OLAP Product: TM1
- Version: 10.2.2
- Excel Version: 2010
Re: Stuck on a if Condition.. too silly
Thanks. That was stupid of me.