Difference between revisions of "Documentation/How Tos/Calc: IF function"

From Apache OpenOffice Wiki
Jump to: navigation, search
m
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
{{Documentation/MasterTOC
+
{{DISPLAYTITLE:IF function}}
|bookid=1234'''
+
{{Documentation/CalcFunc LogicalTOC
|booktitle=<div style="padding: 8px; font-size: 140%; font-weight: bold; background-color: #9BC0F5;">CALC FUNCTIONS</div>
+
|ShowPrevNext=block
|ShowParttitle=block|parttitle=[[Documentation/How_Tos/Calc:_Logical_functions|<div style="font-size: 140%;">Logical  Functions]]
+
|PrevPage=Documentation/How_Tos/Calc:_FALSE_function
|ShowNextPage=block|NextPage=Documentation/How_Tos/Calc:_NOT_function
+
|NextPage=Documentation/How_Tos/Calc:_NOT_function
|ShowPrevPage=block|PrevPage=Documentation/How_Tos/Calc:_FALSE_function
+
}}__NOTOC__
|ShowPrevPart=block|PrevPart=Documentation/How_Tos/Calc:_Information_functions
+
|ShowNextPart=block|NextPart=Documentation/How_Tos/Calc:_Mathematical_functions
+
|toccontent= <div style="padding: 4px; font-size: 130%; font-weight: hidden; background-color:#DCE9FC;">FUNCTIONS</div>
+
 
+
* [[Documentation/How_Tos/Calc:_AND_function|<div style="font-size: 120%;">And]]
+
* [[Documentation/How_Tos/Calc:_FALSE_function|<div style="font-size: 120%;">False]]
+
* [[Documentation/How_Tos/Calc:_IF_function|<div style="font-size: 120%; border-style: double; border-color:#778899;">If]]
+
* [[Documentation/How_Tos/Calc:_NOT_function|<div style="font-size: 120%;">Not]]
+
* [[Documentation/How_Tos/Calc:_OR_function|<div style="font-size: 120%;">Or]]
+
* [[Documentation/How_Tos/Calc:_TRUE_function|<div style="font-size: 120%;">True]]
+
}}__TOC__
+
  
 
== IF  ==
 
== IF  ==
Line 38: Line 27:
 
: returns <tt>'''TRUE'''</tt> - because both <tt>'''value1'''</tt> and <tt>'''value2'''</tt> have been omitted and 2 is more than 1.
 
: returns <tt>'''TRUE'''</tt> - because both <tt>'''value1'''</tt> and <tt>'''value2'''</tt> have been omitted and 2 is more than 1.
 
<tt>'''IF(1=2; 1/0; SQRT(4))'''</tt>
 
<tt>'''IF(1=2; 1/0; SQRT(4))'''</tt>
: returns <tt>'''2'''</tt>, the square root of <tt>'''4'''</tt>. <tt>'''IF()'''</tt> only calculates the value chosen - in this case <tt>'''1/0'''</tt> would give a #DIV/0! error, but is not calculated.
+
: returns <tt>'''2'''</tt>, the square root of <tt>'''4'''</tt>. <tt>'''IF()'''</tt> only calculates the value chosen - in this case <tt>'''1/0'''</tt> would give an error #DIV/0!, but is not calculated.
  
{{Documentation/SeeAlso|
+
{{SeeAlso|EN|
 
* [[Documentation/How_Tos/Calc: COUNTIF function|COUNTIF]]
 
* [[Documentation/How_Tos/Calc: COUNTIF function|COUNTIF]]
 
* [[Documentation/How_Tos/Calc: SUMIF function|SUMIF]]
 
* [[Documentation/How_Tos/Calc: SUMIF function|SUMIF]]

Latest revision as of 13:43, 31 January 2024

IF

Returns one of two values, depending on a test condition.

Syntax:

IF(test; value1; value2) where:

test is or refers to a logical value or expression that returns a logical value (TRUE or FALSE).
value1 is the value that is returned by the function if test yields TRUE.
value2 is the value that is returned by the function if test yields FALSE.


If value2 is omitted it is assumed to be FALSE; if value1 is also omitted it is assumed to be TRUE.

Example:

IF(A1>5; 100; "too small")

returns the number 100 if A1 is greater than 5, and the text "too small" otherwise.

IF(1>2; "nonsense")

returns FALSE - because value2 has been omitted and 1 is not greater than 2.

IF(2>1)

returns TRUE - because both value1 and value2 have been omitted and 2 is more than 1.

IF(1=2; 1/0; SQRT(4))

returns 2, the square root of 4. IF() only calculates the value chosen - in this case 1/0 would give an error #DIV/0!, but is not calculated.



See Also
Retrieved from "https://wiki.openoffice.org/w/index.php?title=Documentation/How_Tos/Calc:_IF_function&oldid=259827"
Views
Personal tools
Navigation
Tools
In other languages