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
資料表、控制項、訊號或列舉中擷取屬性。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
價格 < 100 And Slider1.Value = 20or Price < 100 And Slider1.Value = 20
邏輯結合,相當於 And 函式Logical conjunction, equivalent to the And function
||Or|| or Or   價格 < 100 || Slider1.Value = 20價格 < 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. 建立或匯入名為 Inventory 的集合,並將其顯示在資源庫中,如顯示資源庫中的影像和文字中的第一個程序所述。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.