邏輯函式

This category contains the Logical functions.

Handling non-logical arguments in logical functions

若要使用此指令...

[插入] - [函式] - [類別] [邏輯]


AND

如果所有引數是 TRUE 則傳回 TRUE。 如果其中一個元素是 FALSE,此函式會傳回 FALSE 值。

這些引數可能是本身傳回邏輯值的邏輯表示式 (TRUE, 1<5, 2+3=7, B8<10),或包含邏輯值的陣列 (A1:C3)。

語法

AND(LogicalValue1; LogicalValue2 ...LogicalValue30)

LogicalValue1; LogicalValue2 ...LogicalValue30 are conditions to be checked. All conditions can be either TRUE or FALSE. If a range is entered as a parameter, the function uses all values of the range. The result is TRUE if the logical value in all cells within the cell range is TRUE.

範例

即將檢查條目 12<13、14>12 與 7<6 的邏輯值:

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

=AND (FALSE;TRUE) 傳回 FALSE。

FALSE

傳回邏輯值 FALSE。 FALSE() 函式不需要任何引數,而且會一直傳回邏輯值 FALSE。

語法

FALSE()

範例

=FALSE() 傳回 FALSE。

=NOT(FALSE()) 傳回 TRUE。

IF

指定要執行的邏輯測試。

語法

IF(Test; ThenValue; OtherwiseValue)

Test 是任意值或可為 TRUE 或 FALSE 的表示式。

若邏輯測試為 TRUE,則 (選擇性) 傳回 ThenValue

若邏輯測試為 FALSE,則 (選擇性) 傳回 OtherwiseValue

In the LibreOffice Calc functions, parameters marked as "optional" can be left out only when no parameter follows. For example, in a function with four parameters, where the last two parameters are marked as "optional", you can leave out parameter 4 or parameters 3 and 4, but you cannot leave out parameter 3 alone.

範例

=IF(A1>5;100;"太小") 若 A1 中的值大於 5,就會在目前的儲存格中輸入值 100;否則,會輸入文字「太小」(不包括角括號)。

NOT

反轉邏輯值。

語法

NOT(LogicalValue)

LogicalValue 是要反轉的值。

範例

=NOT(A)。若 A=TRUE,則 NOT(A) 將評估 FALSE。

OR

如果至少一個引數是 TRUE 則傳回 TRUE。 如果所有引數邏輯值均為 FALSE,此函式則傳回值 FALSE。

這些引數可能是本身傳回邏輯值的邏輯表示式 (TRUE, 1<5, 2+3=7, B8<10),或包含邏輯值的陣列 (A1:C3)。

語法

OR(LogicalValue1; LogicalValue2 ...LogicalValue30)

LogicalValue1; LogicalValue2 ...LogicalValue30 are conditions to be checked. All conditions can be either TRUE or FALSE. If a range is entered as a parameter, the function uses all values of the range.

範例

即將檢查條目 12<11、13>22 與 45=45 的邏輯值。

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

=OR(FALSE;TRUE) 傳回 TRUE。

TRUE

邏輯值設為 TRUE。 TRUE() 函式不需要任何引數,而且會一直傳回邏輯值 TRUE。

語法

TRUE()

範例

如果 A=TRUE 而 B=FALSE,下列範例出現:

=AND(A;B) 傳回 FALSE。

=OR(A;B) 傳回 TRUE。

=NOT(AND(A;B)) 傳回 TRUE。

XOR

Returns true if an odd number of arguments evaluates to TRUE.

這些引數可能是本身傳回邏輯值的邏輯表示式 (TRUE, 1<5, 2+3=7, B8<10),或包含邏輯值的陣列 (A1:C3)。

語法

OR(LogicalValue1; LogicalValue2 ...LogicalValue30)

範例

=AND (FALSE;TRUE) 傳回 FALSE。

=OR(FALSE;TRUE) 傳回 TRUE。

=OR(FALSE;TRUE) 傳回 TRUE。