PowerApps 中的运算符和数据类型Operators and data types in PowerApps

其中的某些运算符依赖于作者的语言。Some of these operators are dependent on the language of the author. 有关详细信息,请参阅全局应用See Global apps for more information.

符号Symbol 类型Type 语法Syntax 说明Description
.. 属性选择器Property Selector Slider1.Value
Color.Red
Acceleration.X
Slider1.Value
Color.Red
Acceleration.X
、控件、信号 或枚举中提取属性。Extracts a property from a table, control, signal, or enumeration. 对于向后兼容性,!For backwards compatibility, ! 也可以使用。may also be used.
..
[或 , ,具体取决于语言][or , depending on the language]
小数分隔符Decimal separator 1.231.23
[或 1,23,具体取决于语言][or 1,23 depending on the language]
整数和小数之间的分隔符。Separator between whole and fractional parts of a number. 字符取决于语言。The character is dependent on the language.
( )( ) 括号Parentheses Filter(T, A < 10)Filter(T, A < 10)

(1 + 2) * 3(1 + 2) * 3
强制执行优先顺序和较大表达式中的组子表达式Enforces precedence order, and groups sub-expressions in a larger expression
+ 算数运算符Arithmetic operators 1 + 21 + 2 加法Addition
-   2 - 12 - 1 减法和减号Subtraction and sign
\*   2 * 32 * 3 乘法Multiplication
/   2 / 32 / 3 除法(另请参阅 Mod 函数)Division (also see the Mod function)
^   2 ^ 32 ^ 3 求幂,相当于 Power 函数Exponentiation, equivalent to the Power function
%   20%20% 百分比(相当于"* 1/100")Percentage (equivalent to "* 1/100")
= 比较运算符Comparison operators Price = 100Price = 100 等于Equal to
>   Price > 100Price > 100 大于Greater than
>=   Price >= 100Price >= 100 大于或等于Greater than or equal to
<   Price < 100Price < 100 小于Less than
<=   Price <= 100Price <= 100 小于或等于Less than or equal to
<>   Price <> 100Price <> 100 不等于Not equal to
& 字符串连接运算符String concatenation operator "hello" & " " & "world""hello" & " " & "world" 使多个字符串连续显示Makes multiple strings appear continuous
&& 或 And&& or And 逻辑运算符Logical operators Price < 100 && Slider1.Value = 20Price < 100 && Slider1.Value = 20
或 Price < 100 And Slider1.Value = 20or Price < 100 And Slider1.Value = 20
逻辑关联,相当于 And 函数Logical conjunction, equivalent to the And function
||Or|| or Or   Price < 100 || Slider1.Value = 20Price < 100 Or Slider1.Value = 20Price < 100 || Slider1.Value = 20 or Price < 100 Or Slider1.Value = 20 逻辑或,相当于 Or 函数Logical disjunction, equivalent to the Or function
!! Notor Not   !(Price < 100)Not (Price < 100)!(Price < 100) or Not (Price < 100) 逻辑非,相当于 Not 函数Logical negation, equivalent to the Not function
exactinexactin 成员运算符Membership operators Gallery1.Selected exactin SavedItemsGallery1.Selected exactin SavedItems 属于集合或表Belonging to a collection or a table
exactinexactin   "Windows" exactin “To display windows in the Windows operating system...”"Windows" exactin “To display windows in the Windows operating system...” 子字符串测试(区分大小写)Substring test (case-sensitive)
inin   Gallery1.Selected in SavedItemsGallery1.Selected in SavedItems 属于集合或表Belonging to a collection or a table
inin   "The" in "The keyboard and the monitor...""The" in "The keyboard and the monitor..." 子字符串测试(不区分大小写)Substring test (case-insensitive)
@ 消除歧义运算符Disambiguation operator MyTable[@fieldname]MyTable[@fieldname] 字段消除歧义Field disambiguation
@   [@MyVariable][@MyVariable] 全局消除歧义Global disambiguation
,,
[或 ; ,具体取决于语言][or ; depending on the language]
列表分隔符List separator If( X < 10, "Low", "Good" )If( X < 10, "Low", "Good" )
{ X: 12, Y: 32 }{ X: 12, Y: 32 }
[ 1, 2, 3 ][ 1, 2, 3 ]
[or If( X < 10; "Low"; "Good" )
{ FirstName: "Jane"; LastName: "Doe" }
[ 1; 2; 3 ]
]
[or If( X < 10; "Low"; "Good" )
{ FirstName: "Jane"; LastName: "Doe" }
[ 1; 2; 3 ]
]
分隔:Separates: . 此字符取决于语言。This characters is dependent on the language.
;;
[或 ;; ,具体取决于语言][or ;; depending on the language]
公式链接Formula chaining Collect(T, A); Navigate(S1, "")Collect(T, A); Navigate(S1, "")
[or Collect(T; A);; Navigate(S1; "")][or Collect(T; A);; Navigate(S1; "")]
在行为属性中分隔函数的调用。Separate invocations of functions in behavior properties. 链接运算符取决于语言。The chaining operator is dependent on the language.
ParentParent Parent 运算符Parent operator Parent.FillParent.Fill 控件容器属性的访问权限Access to properties of a control container
ThisItemThisItem ThisItem 运算符ThisItem operator ThisItem.FirstNameThisItem.FirstName 库或窗体控件字段的访问权限Access to fields of a Gallery or form control

in 和 exactin 运算符in and exactin operators

可以使用 inexactin 运算符查找数据源中的字符串,如集合或导入的表。You can use the in and exactin operators to find a string in a data source, such as a collection or an imported table. in 运算符标识匹配项(不区分大小写),而 exactin 运算符仅在大小写相同时标识匹配项。The in operator identifies matches regardless of case, and the exactin operator identifies matches only if they're capitalized the same way. 下面是一个示例:Here's an example:

  1. 创建或导入一个名为“清单”的集合,并在库中显示它,如在库中显示图像和文本所述的第一个过程。Create or import a collection named Inventory, and show it in a gallery, as the first procedure in Show images and text in a gallery describes.
  2. 将库的 Items 属性设置为以下公式:Set the Items property of the gallery to this formula:
    Filter(Inventory, "E" in ProductName)Filter(Inventory, "E" in ProductName)

    库显示除 Callisto 以外的所有产品,因为该产品的名称是唯一不包含你所指定的字母的产品。The gallery shows all products except Callisto because the name of that product is the only one that doesn't contain the letter you specified.

  3. 将库的 Items 属性更改为以下公式:Change the Items property of the gallery to this formula:
    Filter(Inventory, "E" exactin ProductName)Filter(Inventory, "E" exactin ProductName)

    库仅显示 Europa,因为只有它的名称中包含你所指定的字母。The gallery shows only Europa because only its name contains the letter that you specified in the case that you specified.

ThisItem 运算符ThisItem operator

通过将数据绑定到表或集合,可以在编辑窗体显示窗体控件中显示数据。You can show data in Gallery, Edit form, or Display form controls by binding it to a table or a collection. 这些控件是其他卡和控件的容器。These controls are a container for other cards and controls. 容器内的每个卡或控件均能通过 ThisItem 运算符访问绑定的数据。Each card or control within the container can access the bound data through the ThisItem operator.

使用 ThisItem 运算符指定外部控件内的每个卡或控件的数据的You use the ThisItem operator to specify the column of data that each card or control within the outer control. 例如,在库中显示图像和文本的产品库中的运算符指定图像控件显示产品设计、上部标签显示产品名称,而下部标签显示库存单位数。For example, that operator in the product gallery for Show images and text in a gallery specified that the image control showed the product design, the upper label showed the product name, and the lower label showed the number of units in stock.

对于嵌套库,ThisItem 指的是最里面的库的项。For nested galleries, ThisItem refers to the innermost gallery's items. 假定内部和外部库的行字段不冲突,还可以直接使用未限定的字段(列)名称。Assuming the row fields in the inner and outer galleries don't conflict, you can also use the unqualified field (column) names directly. 此方法启用内部库中的规则,以引用外部库的项。This approach enables rules in an inner gallery to refer to an outer gallery's items.

Parent 运算符Parent operator

某些控件托管其他控件。Some controls host other controls. 例如,屏幕编辑窗体显示窗体控件都是控件的容器。For example, Screen, Gallery, Card, Edit form, and Display form controls are all containers for controls. 我们将托管控件称为控件内部的“父级”。We call the hosting control the "parent" of the controls within.

PowerApps 中的任何控件都可由应用内任何位置的名称引用。Any control in PowerApps can be referenced by name from anywhere within the app. Screen1 可能是应用中屏幕的名称。Screen1 may be the name of a screen in your app. 若要检索此屏幕的背景色,可以使用 Screen1.FillTo retrieve the background color of this screen, you can use Screen1.Fill.

此屏幕上的控件具有其他选项。Controls on this screen have another option. 它们可以使用相对引用:Parent.FillThey can use a relative reference: Parent.Fill. Parent 运算符指的是托管此控件,并使其所有属性可用的控件。The Parent operator refers to the control that hosts this control, making available all of its properties. Parent非常有用,因为它不依赖于控件的名称。Using Parent is helpful because it doesn't depend on the name of the control. 可以复制并粘贴容器控件,无需调整容器内的任何引用。You can copy and paste a container control without needing to adjust any references within the container. 在读取公式时,此运算符还使子控件和父控件之间的关系更为明确。This operator also makes the relationship between child and parent controls clearer when reading formulas.

消除歧义运算符Disambiguation operator

某些函数创建记录作用域,从而在处理每个记录时访问表的字段,例如 FilterAddColumnsSumSome functions create record scopes for accessing the fields of table while processing each record, such as Filter, AddColumns, and Sum. 使用记录作用域添加的字段名称将替代应用中来自其他位置的同一名称。Field names added with the record scope override the same names from elsewhere in the app. 在此情况下,仍可以使用 @ 消除歧义运算符访问来自记录作用域外部的值:When this happens, you can still access values from outside the record scope with the @ disambiguation operator:

  • 若要访问来自嵌套记录作用域的值,请使用 @ 运算符,其中所操作的表名称使用模式 Table[@*FieldName]。To access values from nested record scopes, use the **@* operator with the name of the table being operated upon using the pattern Table[@FieldName].
  • 若要访问全局值,如数据源、集合和上下文变量,请使用模式 [@ObjectName](无需指派表)。To access global values, such as data sources, collections, and context variables, use the pattern *[@ObjectName*] (without a table designation).

有关详细信息和示例,请参阅记录作用域上探讨的内容。For more information and examples, see the discussion on record scopes.