Hi All,
I am trying code with two if statements one- IFCellsupdatable and other one if CellputN IFvAccount.
I am not able to save and execute TI process after the multiple try "END" out of place problem. I thought to take your suggestion to know where I am making mistake.
IF(CellIsUpdateable(TargetCube, elmCurrency, elmSource, vAccount, elmLOB1, elmEntity1, elmVersion, elmMeasure, elmPeriod) =1);
ELSE;
IF(vAccount @= '620000' );
CellPutN(Value,TargetCube, elmCurrency, elmSource, vAccount, elmLOB1, elmEntity1, elmVersion, elmMeasure, elmPeriod);
ENDIF;
IF(CellIsUpdateable(TargetCube, elmCurrency, elmSource, vAccount, elmLOB1, elmEntity1, elmVersion, elmMeasure, elmPeriod)=1);
ELSE;
IF(vAccount @= '640000' );
CellPutN(Value,TargetCube, elmCurrency, elmSource, vAccount, elmLOB2, elmEntity2, elmVersion, elmMeasure, elmPeriod);
ENDIF;
END;
Thanks
IF Statement
- Steve Rowe
- Site Admin
- Posts: 2415
- Joined: Wed May 14, 2008 4:25 pm
- OLAP Product: TM1
- Version: TM1 v6,v7,v8,v9,v10,v11+PAW
- Excel Version: Nearly all of them
-
- Community Contributor
- Posts: 292
- Joined: Tue Sep 06, 2016 7:55 am
- OLAP Product: TM1
- Version: 10.1.1
- Excel Version: Excel 2010
Re: IF Statement
If simply removing the End makes that code logical then I really do not know as much as I think i do, and I don't think I know that much anyway!
Assuming you have provided all the code and not just some snippet then I reckon the code needs to look something like or along the lines of,
IF(CellIsUpdateable(TargetCube, elmCurrency, elmSource, vAccount, elmLOB1, elmEntity1, elmVersion, elmMeasure, elmPeriod) =1);
IF(vAccount @= '620000' );
CellPutN(Value,TargetCube, elmCurrency, elmSource, vAccount, elmLOB1, elmEntity1, elmVersion, elmMeasure, elmPeriod);
Elseif(vAccount @= '640000' );
CellPutN(Value,TargetCube, elmCurrency, elmSource, vAccount, elmLOB2, elmEntity2, elmVersion, elmMeasure, elmPeriod);
ENDIF;
ENDIF;
Though other than the obvious what concerns me is, and again assuming this is the code in all its glory, that if you are hard coding the vAccount why wouldn't you simply hard code '620000' and '640000' in the CellPutN rather than have the if? Also you have 2 celisupdateables in your code which are identical, yet the cellputn's are different?
Actually given these concerns forget about my code above because the CellisUpdateable makes no sense to me!
Apologies if I have in anyway confused the matter.
Regards, Mark
Assuming you have provided all the code and not just some snippet then I reckon the code needs to look something like or along the lines of,
IF(CellIsUpdateable(TargetCube, elmCurrency, elmSource, vAccount, elmLOB1, elmEntity1, elmVersion, elmMeasure, elmPeriod) =1);
IF(vAccount @= '620000' );
CellPutN(Value,TargetCube, elmCurrency, elmSource, vAccount, elmLOB1, elmEntity1, elmVersion, elmMeasure, elmPeriod);
Elseif(vAccount @= '640000' );
CellPutN(Value,TargetCube, elmCurrency, elmSource, vAccount, elmLOB2, elmEntity2, elmVersion, elmMeasure, elmPeriod);
ENDIF;
ENDIF;
Though other than the obvious what concerns me is, and again assuming this is the code in all its glory, that if you are hard coding the vAccount why wouldn't you simply hard code '620000' and '640000' in the CellPutN rather than have the if? Also you have 2 celisupdateables in your code which are identical, yet the cellputn's are different?
Actually given these concerns forget about my code above because the CellisUpdateable makes no sense to me!
Apologies if I have in anyway confused the matter.
Regards, Mark
-
- Posts: 138
- Joined: Mon Apr 26, 2010 12:39 pm
- OLAP Product: cognos
- Version: tm1 9.5
- Excel Version: 2007
Re: IF Statement
Hi Mark,
Sorry for any confusion. I used the Cellsupdatable function - just make sure we do not get the rule applies to cell error while running the TI.
after one more try- I changed the code &(Ampersand)
IF(CellIsUpdateable(TargetCube,
elmCurrency,
elmSource,
vAccount,
elmLOB1,
elmEntity1,
elmVersion,
elmMeasure,
elmPeriod) =1 & vAccount @= '620000');
CellPutN(Value, TargetCube, elmCurrency, elmSource, vAccount, elmLOB1, elmEntity1, elmVersion, elmMeasure, elmPeriod);
ENDIF;
This works fine now- thank you
Sorry for any confusion. I used the Cellsupdatable function - just make sure we do not get the rule applies to cell error while running the TI.
after one more try- I changed the code &(Ampersand)
IF(CellIsUpdateable(TargetCube,
elmCurrency,
elmSource,
vAccount,
elmLOB1,
elmEntity1,
elmVersion,
elmMeasure,
elmPeriod) =1 & vAccount @= '620000');
CellPutN(Value, TargetCube, elmCurrency, elmSource, vAccount, elmLOB1, elmEntity1, elmVersion, elmMeasure, elmPeriod);
ENDIF;
This works fine now- thank you
-
- Posts: 78
- Joined: Tue Mar 18, 2014 8:02 am
- OLAP Product: TM1, Cognos Express
- Version: 10.2.2
- Excel Version: 2013
Re: IF Statement
Performance wise it might be better to split the IF statement:
This way the CellIsUpdateable check is only performed when vAccount equals 620000 and not for every item in your Data tab.
Of course the absolute impact on performance will probably be negligible, but every little bit helps...
Code: Select all
IF(vAccount @= '620000');
IF(CellIsUpdateable(...)=1);
# Do things
ENDIF;
ENDIF;
Of course the absolute impact on performance will probably be negligible, but every little bit helps...