[Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register]

Author Message
tecknode
General User

Joined: 14 Aug 2008
Posts: 9
Location: San Diego, CA

 Posted: Tue Jul 10, 2012 12:13 pm    Post subject: IF Function Error 509 - simple comparison REF: OpenOffice 3.2, Calc =IF(D8>120,H7+1,H7) Cells D8 and H7, numbers Why do I get a 509 error on the above IF function What operator is missing (509 error)?_________________== Tecknomage == Computer Systems Specialist IT Technician
ozzie

Joined: 29 Jul 2010
Posts: 400
Location: victoria

Posted: Tue Jul 10, 2012 12:48 pm    Post subject:

semi colons not commas
 Code: =IF(D8>120;H7+1;H7)

_________________
karolus

Joined: 22 Jun 2011
Posts: 210

Posted: Tue Jul 10, 2012 8:43 pm    Post subject:

Hallo
 Code: =H7+(D8>120)

Karo
keme
Moderator

Joined: 30 Aug 2004
Posts: 2910
Location: Egersund, Norway

Posted: Wed Jul 11, 2012 1:27 am    Post subject:

karolus wrote:
 Code: =H7+(D8>120)
ozzie wrote:
 Code: =IF(D8>120;H7+1;H7)
With current versions of OOo, the two suggestions will yield identical result.

Karolus' solution is more compact and may be more efficient, but it hides the logic and uses the undocumented "feature" of Calc assuming the logical value of TRUE to be the number one. (*)

Ozzie's suggestion preserves logic, and will work the same even if treatment of logical values changes (as may happen if you use different software, or if a software upgrade changes this behaviour).

Use Karolus' solution if file size and/or calculation time is critical, and you do not need portability (i.e. you will not be feeding that spreadsheet file to other software).
Use Ozzie's solution if you envision that others will be developing or debugging the spreadsheet (preserved logic means that the other folks will understand what you tried to do), or if you need portability.

(*) Most software use a zero value to represent FALSE.
TRUE = NOT(FALSE), and with simple handling of twos-complement signed integers (as is common with many programming languages), and the NOT() function inverting all bits, NOT(0) yields -1 (minus one) instead of the expected value of 1.

Also, type safe handling of data, as is enforced with some software and programming languages, will return an error if a logical value (TRUE/FALSE) is found where a numerical value is expected.
These issues do not apply with normal use of the spreadsheet software.
Villeroy
Super User

Joined: 04 Oct 2004
Posts: 10106
Location: Germany

Posted: Wed Jul 11, 2012 1:55 am    Post subject:

 Code: =H7+IF(D8>120;1;0)

_________________
Rest in peace, oooforum.org
Get help on https://forum.openoffice.org
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First
 All times are GMT - 8 Hours Page 1 of 1

 Jump to: Select a forum OpenOffice.org Forums----------------Setup and TroubleshootingOpenOffice.org WriterOpenOffice.org CalcOpenOffice.org ImpressOpenOffice.org DrawOpenOffice.org MathOpenOffice.org BaseOpenOffice.org Macros and APIOpenOffice.org Code Snippets Community Forums----------------General DiscussionSite Feedback
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum