逻辑函数

This category contains the Logical functions.

逻辑函数中非逻辑参数的处理

要访问此命令...

插入 - 函数,在“类别”中选择逻辑


ISNA

如果单元格包含错误值 #N/A (找不到该值),返回逻辑值 TRUE。

如果发生错误,函数返回 FALSE。

语法

ISNA(值)

数值」是指一个要检查的数值或一个表达式。

示例

=ISNA(D3)」返回 FALSE 作为结果。

IFERROR

Returns the value if the cell does not contain an error value, or the alternative value if it does.

tip

This function is available since LibreOffice 4.0.


语法

IFERROR(Value; Alternate_value)

」是当结果为不等于或出错时的返回值或表达式。

备选值: 前面一个参数 (」) 的返回结果为错误的情况下,返回这个备选值。

示例

=ISERROR(C8) 返回 TRUE,其中单元格 C8 包含 =1/0」,因为 1/0 是错误值。

=ISERROR(C8) 返回 TRUE,其中单元格 C8 包含 =1/0」,因为 1/0 是错误值。

IFS

IFS 是多重 IF 函数。

SWITCH

SWITCH 将「表达式」与「值1」到「值n」依次做比较,并返回与表达式相等的第一个值所对应的结果。如果所有值均未匹配,且已给出默认值 (default_result),则返回默认值。

AND

如果所有参数都为 TRUE,则返回 TRUE。如果某个参数为 FALSE,则该函数返回 FALSE。

参数应该是能返回逻辑值的逻辑表达式 (TRUE, 1<5, 2+3=7, B8<10),或包含逻辑值的矩阵 (A1:C3)。

语法

AND(Logical 1 [; Logical 2 [; … [; Logical 255]]])

Logical 1, Logical 2, … , Logical 255 are boolean values, references to cells or to cell ranges of logical values.

note

This function ignores any text or empty cell within a data range. If you suspect wrong results from this function, look for text in the data ranges. To highlight text contents in a data range, use the value highlighting feature.


示例

检查 12<13; 14>12 和 7<6 的逻辑值:

=AND(12<13;14>12;7<6)」返回 FALSE。

=AND(FALSE();TRUE()) returns FALSE.

FALSE

返回逻辑值 FALSE。函数 FALSE() 不需要任何参数,并始终返回逻辑值 FALSE。

语法

FALSE()

示例

=FALSE()」返回 FALSE

=NOT(FALSE())」返回 TRUE

IF

指定要执行的逻辑测试。

语法

IF(Test [; [ThenValue] [; [OtherwiseValue]]])

Test」是 TRUE 或 FALSE 的任意值或表达式。

ThenValue」 (可选) 是逻辑测试结果为 TRUE 时返回的值。

OtherwiseValue」 (可选) 是逻辑测试结果为 FALSE 时返回的值。

在 LibreOffice Calc 函数中,只有其后没有参数时,才可省略标记为「可选」的参数。例如,在带有四个参数的函数中,最后两个参数标记为「可选」时,可省略参数 4 或参数 3 和 4,但不能单独省略参数 3。

示例

=IF(A1>5;100;"too small") If the value in A1 is greater than 5, the value 100 is returned; otherwise, the text too small is returned.

=IF(A1>5;;"too small") If the value in A1 is greater than 5, the value 0 is returned because empty parameters are considered to be 0; otherwise, the text too small is returned.

=IF(A1>5;100;) If the value in A1 is less than 5, the value 0 is returned because the empty OtherwiseValue is interpreted as 0; otherwise 100 is returned.

NOT

补余 (反转) 一个逻辑值。

语法

NOT(LogicalValue)

逻辑值」是要补余的数值。

示例

=NOT(A)」。如果 A=TRUE,则 NOT(A) 为 FALSE。

OR

至少有一个参数为 TRUE 时,函数返回 TRUE。如果所有参数的逻辑值都为 FALSE,该函数返回 FALSE。

参数应该是能返回逻辑值的逻辑表达式 (TRUE, 1<5, 2+3=7, B8<10),或包含逻辑值的矩阵 (A1:C3)。

语法

OR(Logical 1 [; Logical 2 [; … [; Logical 255]]])

Logical 1, Logical 2, … , Logical 255 are boolean values, references to cells or to cell ranges of logical values.

note

This function ignores any text or empty cell within a data range. If you suspect wrong results from this function, look for text in the data ranges. To highlight text contents in a data range, use the value highlighting feature.


示例

检查 12<11; 13>22 以及 45=45 的逻辑值。

=OR(12<11;13>22;45=45)」返回 TRUE。

=OR(FALSE();TRUE()) returns TRUE.

TRUE

逻辑值设置为 TRUE。函数 TRUE() 不需要任何参数,并始终返回逻辑值 TRUE。

语法

TRUE()

示例

当 A=TRUE 且 B=FALSE 时,出现下列结果:

=AND(A;B)」返回 FALSE

=OR(A;B)」返回 TRUE

=NOT(AND(A;B))」返回 TRUE

XOR

若值为TRUE的参数的个数为奇数时,则返回TRUE。

参数可以是返回逻辑值的表达式 (TRUE, 1<5, 2+3=7, B8<10),或者是包含逻辑值的数组 (A1:C3)。

tip

This function is available since LibreOffice 4.0.


语法

XOR(Logical 1 [; Logical 2 [; … [; Logical 255]]])

Logical 1, Logical 2, … , Logical 255 are boolean values, references to cells or to cell ranges of logical values.

示例

=XOR(TRUE();TRUE()) returns FALSE

=XOR(TRUE();TRUE();TRUE()) returns TRUE

=XOR(FALSE();TRUE()) returns TRUE

请支持我们!