PowerApps 中的 And、Or 和 Not 函数And, Or, and Not functions in PowerApps

布尔逻辑函数,常用于操作比较结果和测试结果。Boolean logic functions, commonly used to manipulate the results of comparisons and tests.

说明Description

如果 And 函数的所有参数均为 true,则此函数返回 trueThe And function returns true if all of its arguments are true. && 运算符等效于 AndThe && operator is equivalent to And.

如果 Or 函数的任何参数为 true,则此函数返回 trueThe Or function returns true if any of its arguments are true. || 运算符等效于 OrThe || operator is equivalent to Or.

如果 Not 函数的参数为 false,则此函数返回 true;如果其参数为 true,则返回 falseThe Not function returns true if its argument is false; it returns false if its argument is true. !The ! 运算符等效于 Notoperator is equivalent to Not.

这些函数使用逻辑值。These functions work with logical values. 不能直接向这些函数传递数字或字符串;而是必须执行比较或测试。They can't be passed a number or a string directly; instead a comparison or test must be made. 例如,诸如 x > 1 的比较是一个逻辑公式,如果 x 大于 1,则计算结果为布尔值 trueFor example, a comparison such as x > 1 is a logical formula that evaluates to the Boolean value true if x is greater than 1. 如果 x 小于 1,则此公式的计算结果为 falseIf x is less than 1, the formula evaluates to false.

语法Syntax

And( LogicalFormula1, LogicalFormula2 [, LogicalFormula3, ... ] )And( LogicalFormula1, LogicalFormula2 [, LogicalFormula3, ... ] )
Or( LogicalFormula1, LogicalFormula2 [, LogicalFormula3, ... ] )Or( LogicalFormula1, LogicalFormula2 [, LogicalFormula3, ... ] )
Not( LogicalFormula )Not( LogicalFormula )

  • LogicalFormula(s) - 必需。LogicalFormula(s) - Required. 要计算和运算的逻辑公式。Logical formulas to evaluate and operate on.

示例Examples

分步操作Step by step

使用此函数确定滑块的值是否在 50 到 100 范围之外:Use this function to determine whether a slider's value falls outside the 50 to 100 range:

Or(Slider1.Value < 50, Slider1.Value> 100)Or(Slider1.Value < 50, Slider1.Value> 100)

如果中包含“部门”和“薪水”列,则可在“结果”列中使用此函数在所有符合条件的行中显示 true,其中“部门”列中的值为“人力资源”或“薪水”列中的值大于 200000If a table contained a Dept column and a Salary column, you could use this function in a Result column to show true in all rows in which the value in the Dept column was HR or the value in the Salary column was larger than 200000:

Or(Dept = HR, Salary >= 200000)Or(Dept = HR, Salary >= 200000)

或者,使用 || 运算符来获得与之前的公式相同的结果:As an alternative, use the || operator to get the same results as what the previous formulas return:

Slider1.Value < 50 || Slider1.Value> 100Slider1.Value < 50 || Slider1.Value> 100

Dept = "HR" || Salary > 200000Dept = "HR" || Salary > 200000