1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
|
<?xml version="1.0" encoding="UTF-8"?>
<helpdocument version="1.0">
<!--
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<meta>
<topic id="textscalc0104060105xml" indexer="include">
<title id="tit">Logical Functions</title>
<filename>/text/scalc/01/04060105.xhp</filename>
</topic>
</meta>
<body>
<bookmark branch="index" id="bm_id3153484"><bookmark_value>logical functions</bookmark_value>
<bookmark_value>Function Wizard; logical</bookmark_value>
<bookmark_value>functions; logical functions</bookmark_value>
</bookmark>
<h1 id="hd_id3153484">Logical Functions</h1>
<paragraph id="par_id3149312" role="paragraph"><variable id="logicaltext">This category contains the <emph>Logical</emph> functions.
</variable></paragraph>
<h3 id="hd_id631520887352751">Handling non-logical arguments in logical functions</h3>
<list type="unordered">
<listitem>
<paragraph id="par_id431520887384579" role="listitem">Zero (0) is equivalent to FALSE and all other numbers are equivalent to TRUE.</paragraph>
</listitem>
<listitem>
<paragraph id="par_id881520887475288" role="listitem">Empty cells and text in cells are ignored.</paragraph>
</listitem>
<listitem>
<paragraph id="par_id461520887504085" role="listitem">A #VALUE error is raised if all arguments are ignored.</paragraph>
</listitem>
<listitem>
<paragraph id="par_id591520888006686" role="listitem">A #VALUE error is raised if one argument is direct text (not text in a cell).</paragraph>
</listitem>
<listitem>
<paragraph id="par_id321520889630477" role="listitem">Errors as argument lead to an error.</paragraph>
</listitem>
</list>
<section id="howtoget">
<embed href="text/scalc/00/00000404.xhp#logical"/>
</section>
<sort order="asc" descendant="h2">
<section id="Section10">
<embed href="text/scalc/01/04060104.xhp#isna"/>
</section>
<section id="Section9">
<embed href="text/scalc/01/04060104.xhp#iferror"/>
</section>
<section id="Section8">
<embed href="text/scalc/01/func_ifs.xhp#ifsfunction01"/>
</section>
<section id="Section7">
<embed href="text/scalc/01/func_switch.xhp#switch01"/>
</section>
<section id="Section6">
<bookmark branch="index" id="bm_id3147505"><bookmark_value>AND function</bookmark_value>
</bookmark>
<bookmark branch="hid/SC_HID_FUNC_UND" id="bm_id3145320" localize="false"/>
<h2 id="hd_id3147505">AND</h2>
<paragraph id="par_id3153959" role="paragraph"><ahelp hid="HID_FUNC_UND">Returns TRUE if all arguments are TRUE.</ahelp> If one of the elements is FALSE, this function returns the FALSE value.</paragraph>
<paragraph id="par_id3146100" role="paragraph">The arguments are either logical expressions themselves (TRUE, 1<5, 2+3=7, B8<10) that return logical values, or arrays (A1:C3) containing logical values.</paragraph>
<embed href="text/scalc/01/common_func.xhp#sectionsyntax"/>
<paragraph id="par_id3159123" role="code">AND(<embedvar href="text/scalc/01/ful_func.xhp#logical255_1" markup="keep"/>)</paragraph>
<embed href="text/scalc/01/ful_func.xhp#logical255"/>
<embed href="text/scalc/01/common_func.xhp#datenumbersequencenote"/>
<embed href="text/scalc/01/common_func.xhp#sectionexample"/>
<paragraph id="par_id3153123" role="paragraph">The logical values of entries 12<13; 14>12, and 7<6 are to be checked:</paragraph>
<paragraph id="par_id3145632" role="paragraph">
<item type="input">=AND(12<13;14>12;7<6)</item> returns FALSE.</paragraph>
<paragraph id="par_id3149946" role="paragraph">
<item type="input">=AND(FALSE();TRUE())</item> returns FALSE.</paragraph>
<note id="par_id441723304789320">The <link href="text/scalc/01/04060107.xhp">array formula</link> {=AND(B1:B10;C1:C10)} yields a one-dimensional value of TRUE when all components of B1:B10 and C1:C10 are TRUE. The array expression above does not produce the logical AND per element, and thus does not produce an array of logical values. To compute a logical AND of arrays per element use the * operator in array context. In the example, enter {=B1:B10*C1:C10}.</note>
</section>
<section id="Section5">
<bookmark branch="index" id="bm_id3149015"><bookmark_value>FALSE function</bookmark_value>
</bookmark>
<bookmark branch="hid/SC_HID_FUNC_FALSCH" id="bm_id3154678" localize="false"/>
<h2 id="hd_id3149015">FALSE</h2>
<paragraph id="par_id3149890" role="paragraph"><ahelp hid="HID_FUNC_FALSCH">Returns the logical value FALSE.</ahelp> The FALSE() function does not require any arguments, and always returns the logical value FALSE.</paragraph>
<embed href="text/scalc/01/common_func.xhp#sectionsyntax"/>
<paragraph id="par_id3150030" role="code">FALSE()</paragraph>
<embed href="text/scalc/01/common_func.xhp#sectionexample"/>
<paragraph id="par_id3154842" role="paragraph">
<item type="input">=FALSE()</item> returns FALSE</paragraph>
<paragraph id="par_id3147468" role="paragraph">
<item type="input">=NOT(FALSE())</item> returns TRUE</paragraph>
</section>
<section id="Section4">
<bookmark branch="index" id="bm_id3150141"><bookmark_value>IF function</bookmark_value>
</bookmark>
<bookmark branch="hid/SC_HID_FUNC_WENN" id="bm_id3152789" localize="false"/>
<h2 id="hd_id3150141">IF</h2>
<paragraph id="par_id3148740" role="paragraph"><ahelp hid="HID_FUNC_WENN">Specifies a logical test to be performed.</ahelp></paragraph>
<embed href="text/scalc/01/common_func.xhp#sectionsyntax"/>
<paragraph id="par_id3154558" role="code">IF(Test [; [ThenValue] [; [OtherwiseValue]]])</paragraph>
<paragraph id="par_id3149727" role="paragraph">
<emph>Test</emph> is any value or expression that can be TRUE or FALSE.</paragraph>
<paragraph id="par_id3155828" role="paragraph">
<emph>ThenValue</emph> (optional) is the value that is returned if the logical test is TRUE.</paragraph>
<paragraph id="par_id3154811" role="paragraph">
<emph>OtherwiseValue</emph> (optional) is the value that is returned if the logical test is FALSE.</paragraph>
<paragraph id="par_idN107FA" role="paragraph" localize="false">
<embedvar href="text/scalc/00/00000004.xhp#optional"/>
</paragraph>
<embed href="text/scalc/01/common_func.xhp#sectionexample"/>
<paragraph id="par_id3150867" role="paragraph">
<input>=IF(A1>5;100;"too small")</input> If the value in <literal>A1</literal> is greater than <literal>5</literal>, the value <literal>100</literal> is returned; otherwise, the text <literal>too small</literal> is returned.</paragraph>
<paragraph role="paragraph" id="par_id71607569817532">
<input>=IF(A1>5;;"too small")</input> If the value in <literal>A1</literal> is greater than <literal>5</literal>, the value <literal>0</literal> is returned because empty parameters are considered to be <literal>0</literal>; otherwise, the text <literal>too small</literal> is returned.</paragraph>
<paragraph role="paragraph" id="par_id11607570458867"><input>=IF(A1>5;100;)</input> If the value in <literal>A1</literal> is less than <literal>5</literal>, the value <literal>0</literal> is returned because the empty <emph>OtherwiseValue</emph> is interpreted as <literal>0</literal>; otherwise <literal>100</literal> is returned.</paragraph>
</section>
<section id="Section3">
<bookmark branch="index" id="bm_id3155954"><bookmark_value>NOT function</bookmark_value>
</bookmark>
<bookmark branch="hid/SC_HID_FUNC_NICHT" id="bm_id3145168" localize="false"/>
<h2 id="hd_id3155954">NOT</h2>
<paragraph id="par_id3153570" role="paragraph"><ahelp hid="HID_FUNC_NICHT">Complements (inverts) a logical value.</ahelp></paragraph>
<embed href="text/scalc/01/common_func.xhp#sectionsyntax"/>
<paragraph id="par_id3157996" role="code">NOT(LogicalValue)</paragraph>
<paragraph id="par_id3148766" role="paragraph">
<emph>LogicalValue</emph> is any value to be complemented.</paragraph>
<embed href="text/scalc/01/common_func.xhp#sectionexample"/>
<paragraph id="par_id3150132" role="paragraph">
<item type="input">=NOT(A)</item>. If A=TRUE then NOT(A) will evaluate FALSE.</paragraph>
</section>
<section id="Section2">
<bookmark branch="index" id="bm_id3148394"><bookmark_value>OR function</bookmark_value>
</bookmark>
<bookmark branch="hid/SC_HID_FUNC_ODER" id="bm_id3155620" localize="false"/>
<h2 id="hd_id3148394">OR</h2>
<paragraph id="par_id3156060" role="paragraph"><ahelp hid="HID_FUNC_ODER">Returns TRUE if at least one argument is TRUE.</ahelp> This function returns the value FALSE, if all the arguments have the logical value FALSE.</paragraph>
<paragraph id="par_id3148771" role="paragraph">The arguments are either logical expressions themselves (TRUE, 1<5, 2+3=7, B8<10) that return logical values, or arrays (A1:C3) containing logical values.</paragraph>
<embed href="text/scalc/01/common_func.xhp#sectionsyntax"/>
<paragraph id="par_id3150468" role="code">OR(<embedvar href="text/scalc/01/ful_func.xhp#logical255_1" markup="keep"/>)</paragraph>
<embed href="text/scalc/01/ful_func.xhp#logical255"/>
<embed href="text/scalc/01/common_func.xhp#datenumbersequencenote"/>
<embed href="text/scalc/01/common_func.xhp#sectionexample"/>
<paragraph id="par_id3154870" role="paragraph">The logical values of entries 12<11; 13>22, and 45=45 are to be checked.</paragraph>
<paragraph id="par_id3155371" role="paragraph">
<item type="input">=OR(12<11;13>22;45=45)</item> returns TRUE.</paragraph>
<paragraph id="par_id3158412" role="paragraph">
<item type="input">=OR(FALSE();TRUE())</item> returns TRUE.</paragraph>
<note id="par_id751723304896532">The <link href="text/scalc/01/04060107.xhp">array formula</link> {=OR(B1:B10;C1:C10)} yields a one-dimensional value of FALSE when all components of B1:B10 and C1:C10 are FALSE. The array expression above does not produce the logical OR per element, and thus does not produce an array of logical values. To compute a logical OR of arrays per element use the + operator in array context. In the example, enter {=B1:B10+C1:C10}.</note>
</section>
<section id="Section1">
<bookmark branch="index" id="bm_id3156256"><bookmark_value>TRUE function</bookmark_value>
</bookmark>
<bookmark branch="hid/SC_HID_FUNC_WAHR" id="bm_id3148426" localize="false"/>
<h2 id="hd_id3156256">TRUE</h2>
<paragraph id="par_id3155985" role="paragraph"><ahelp hid="HID_FUNC_WAHR">The logical value is set to TRUE.</ahelp> The TRUE() function does not require any arguments, and always returns the logical value TRUE.</paragraph>
<embed href="text/scalc/01/common_func.xhp#sectionsyntax"/>
<paragraph id="par_id3152590" role="code">TRUE()</paragraph>
<embed href="text/scalc/01/common_func.xhp#sectionexample"/>
<paragraph id="par_id3146148" role="paragraph">If A=TRUE and B=FALSE the following examples appear:</paragraph>
<paragraph id="par_id3083285" role="paragraph">
<item type="input">=AND(A;B)</item> returns FALSE</paragraph>
<paragraph id="par_id3083444" role="paragraph">
<item type="input">=OR(A;B)</item> returns TRUE</paragraph>
<paragraph id="par_id3154314" role="paragraph">
<item type="input">=NOT(AND(A;B))</item> returns TRUE</paragraph>
</section>
<section id="Section0">
<bookmark branch="index" id="bm_id3156257"><bookmark_value>XOR function</bookmark_value>
</bookmark>
<bookmark branch="hid/SC_HID_FUNC_XOR" id="bm_id3148427" localize="false"/>
<h2 id="hd_id3156257">XOR</h2>
<paragraph id="par_id3155987" role="paragraph"><ahelp hid="HID_FUNC_XOR">Returns true if an odd number of arguments evaluates to TRUE.</ahelp></paragraph>
<paragraph id="par_id3148772" role="paragraph">The arguments are either logical expressions themselves (TRUE, 1<5, 2+3=7, B8<10) that return logical values, or arrays (A1:C3) containing logical values.</paragraph>
<embed href="text/scalc/00/avail_release.xhp#4.0"/>
<embed href="text/scalc/01/common_func.xhp#sectionsyntax"/>
<paragraph id="par_id3150469" role="code">XOR(<embedvar href="text/scalc/01/ful_func.xhp#logical255_1" markup="keep"/>)</paragraph>
<embed href="text/scalc/01/ful_func.xhp#logical255"/>
<embed href="text/scalc/01/common_func.xhp#sectionexample"/>
<paragraph id="par_id3083286" role="paragraph">
<item type="input">=XOR(TRUE();TRUE())</item> returns FALSE</paragraph>
<paragraph id="par_id3083445" role="paragraph">
<item type="input">=XOR(TRUE();TRUE();TRUE())</item> returns TRUE</paragraph>
<paragraph id="par_id3154315" role="paragraph">
<item type="input">=XOR(FALSE();TRUE())</item> returns TRUE</paragraph>
</section>
</sort>
<section id="relatedtopics">
<embed href="text/scalc/01/04060100.xhp#drking"/>
</section>
</body>
</helpdocument>
|