We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Logical Expression IF with -ve values

When the Logical Expression "IF" is used with a negative value (passed to the ParseAndComputeFormula method of the calengine), I get an "invalid expression" returned. I am doing something wrong here - the formulas a shown below: formula = "-1.10*4";//returns -4.4 formula = "IF(2 < 3, 1.10*4, 0)"; //returns 4.4 formula = "IF(2 < 3, -1.10*4, 0)"; //returns "invalid expression" Thank you, Simon

7 Replies

AD Administrator Syncfusion Team July 11, 2005 08:37 AM UTC

This is a defect that we will correct. Until there is a version released with this corrected, adding parentheses avoids the problem. formula = "IF(2 < 3, (-1.10*4), 0)"; This is logged as defect #480. http://www.syncfusion.com/support/issues/calculate/Default.aspx?ToDo=view&questId=480

BT Byron Tate July 13, 2005 04:36 PM UTC

I also see a problem that requires parentheses to correct: using GridFormulaEngine in a DataBoundGrid, I add this NamedRange to the engine: engine.AddNamedRange("X","if(true,(a0),b0)"); where a0 and b0 are the zero-reference form used with the engine.CurrentRowNotationEnabled = true; setting. In the above case, the cell value of a0 is put in the "FormulaCell" cell which contains "=X". But if I change the expression like this: engine.AddNamedRange("X","if(false,(a0),b0)"); I get the column header string for column B in the "FormulaCell" cell, instead of column B''s cell value for that row. So it looks like cell reference must be part of an expression to get interpreted correctly. Now, here''s my real problem: I have a mission-critical deployment due Sept 1. Do you have a bug-fix patch coming out soon? I will get beat up if I require my end users to enter parentheses to fix this bug.

BT Byron Tate July 13, 2005 04:59 PM UTC

another case that I really need to work with GridFormulaEngine in GridDataBoundGrid: engine.AddNamedRange("Col1","A0"); engine.AddNamedRange("Col2","b0"); engine.AddNamedRange("X","if(true,Col1+Col2,b0)"); The ''Col1+Col2'' is not recognized as an expr. If a0 and b0 are substituted for Col1 and Col2, it works. But ''if(true,(Col1+Col2),b0)'' works.

AD Administrator Syncfusion Team July 13, 2005 05:50 PM UTC

I can see the behavior you described. As soon as we have researched the problem, I will update this thread.

AD Administrator Syncfusion Team July 14, 2005 12:03 PM UTC

This has been entered as defect #489, and has been corrected in our code base. It will be part of the 3.3 release that should be public shortly (a matter of days, not years). When you put parentheses around an argument in a Function call, then that arguments gets parsed early in the processing of the formula. It is this call to the parse routine that makes the CurrentCellNotation substitutions, and allows things to work. But instead of forcing this early parsing all the time to correct this problem, we added a property that will allow you to turn this on. GridFormulaEngine.ForceParsingOfLibraryFunctionArguments=true will force all function arguments to be parsed at a point where the engine can properly substitute the current row as required by the CurrentRowNotationsEnabled property.

BT Byron Tate July 14, 2005 05:30 PM UTC

thanks. I''ll be eagerly waiting for the release. You must have reasons why you wanted to fix this with a flag setting. I can''t imagine anyone understanding the syntax well enough to figure out how to avoid this problem without the flag turned on.

AD Administrator Syncfusion Team July 14, 2005 11:17 PM UTC

If you are not using Namedranges or CurrentCellNotation, it adds addition overhead that is not needed. Another consideration is that this would be a possible change that would make existing code behave differently. In such cases, adding a property to turn this on might avoid backward compatibility problems.

Live Chat Icon For mobile
Up arrow icon