PowerApps 中的 Table 函式Table function in PowerApps

建立暫存資料表Creates a temporary table.

說明Description

Table 函式會從記錄的引數清單建立資料表。The Table function creates a table from an argument list of records.

資料表的資料行會是所有引數記錄之所有屬性的聯集。The table's columns will be the union of all the properties from all the argument records. 記錄中未包含值的任何資料行中都會新增「空白」值。A blank value is added to any column for which a record doesn't include a value.

資料表是 PowerApps 中的值,如同字串或數字。A table is a value in PowerApps, just like a string or a number. 您可以將資料表指定為函式的引數,而函式可傳回資料表作為結果。You can specify a table as an argument for a function, and functions can return a table as a result. Table 不會建立永久資料表。Table doesn't create a permanent table. 相反地,它會傳回由其引數所構成的暫存資料表。Instead it returns a temporary table made of its arguments. 您可以將此暫存資料表指定為另一個函式的引數,在資源庫中將它視覺化,或將它內嵌在另一個資料表中。You can specify this temporary table as an argument for another function, visualize it in a gallery, or embed it in another table. 請參閱使用資料表以取得詳細資料。See working with tables for more details.

您也可以使用 [ value1, value2, ... ] 語法來建立單欄資料表。You can also create a single-column table with the [ value1, value2, ... ] syntax.

語法Syntax

Table( Record1 [, Record2, ... ] )Table( Record1 [, Record2, ... ] )

  • Record(s) - 必要項目。Record(s) - Required. 要新增至資料表的記錄。The records to add to the table.

範例Examples

  • 將清單方塊的 Items 屬性設定為下列公式:Set the Items property of a listbox to this formula:
    Table({Color:"red"}, {Color:"green"}, {Color:"blue"})Table({Color:"red"}, {Color:"green"}, {Color:"blue"})

    此清單方塊會將每個色彩顯示為選項。The listbox shows each color as an option.

  • 新增文字資源庫,並將其 Items 屬性設定為下列函式:Add a text gallery, and set its Items property to this function:
    Table({Item:"Violin123", Location:"France", Owner:"Fabrikam"}, {Item:"Violin456", Location:"Chile"})Table({Item:"Violin123", Location:"France", Owner:"Fabrikam"}, {Item:"Violin456", Location:"Chile"})

    資源庫會顯示兩筆記錄,兩者都包含項目的名稱和位置。The gallery shows two records, both of which contain the name and location of an item. 只有一筆記錄包含擁有者名稱。Only one record contains the name of the owner.