PowerApps 中的 Remove 和 RemoveIf 函数Remove and RemoveIf functions in PowerApps

数据源删除记录Removes records from a data source.

说明Description

Remove 函数Remove function

使用 Remove 函数从数据源中删除特定的一个或多个记录。Use the Remove function to remove a specific record or records from a data source.

对于集合来说,整个记录必须匹配。For collections, the entire record must match. 可以使用 All 参数删除某个记录的所有副本;否则只会删除记录的一个副本。You can use the All argument to remove all copies of a record; otherwise, only one copy of the record is removed.

RemoveIf 函数RemoveIf function

使用 RemoveIf 函数根据一个或一组条件删除一个或多个记录。Use the RemoveIf function to remove a record or records based on a condition or a set of conditions. 每个条件都可以是其结果为 truefalse 的任意公式,并且可以通过名称引用数据源的Each condition can be any formula that results in a true or false and can reference columns of the data source by name. 将会针对每个记录单独评估每个条件,如果所有条件的评估结果为 true,则会删除该记录。Each condition is evaluated individually for each record, and the record is removed if all conditions evaluate to true.

RemoveRemoveIf 都以的形式返回修改的数据源。Remove and RemoveIf return the modified data source as a table. 只能在行为公式中使用这两个函数。You can use both functions only in behavior formulas.

还可使用 Clear 函数删除数据源中的所有记录。You can also use the Clear function to remove all of the records in a data source.

委派Delegation

当这些函数与数据源一起使用时,不能委派这些函数。When used with a data source, these functions can't be delegated. 将只检索数据源的第一个部分,然后检索应用的函数。Only the first portion of the data source will be retrieved and then the function applied. 结果可能并不是事实的全部。The result may not represent the complete story. 系统会在你创作时显示一个蓝点,提醒注意此限制,并建议尽可能改用可委托的替代项。A blue dot will appear at authoring time to remind you of this limitation and to suggest switching to delegable alternatives where possible. 有关详细信息,请参阅委托概述For more information, see the delegation overview.

语法Syntax

Remove( DataSource, Record1 [, Record2, ... ] [, All ] )Remove( DataSource, Record1 [, Record2, ... ] [, All ] )

  • DataSource – 必需。DataSource – Required. 数据源,其中包含要删除的一个或多个记录。The data source that contains the record or records that you want to remove.
  • Record(s) - 必需。Record(s) – Required. 要删除的一个或多个记录。The record or records to remove.
  • All - 可选。All – Optional. 在集合中,同一记录可能出现多次。In a collection, the same record may appear more than once. 添加 All 参数即可删除记录的所有副本。You can add the All argument to remove all copies of the record.

Remove( DataSource, Table [, All ] )Remove( DataSource, Table [, All ] )

  • DataSource – 必需。DataSource – Required. 数据源,其中包含要删除的记录。The data source that contains the records that you want to remove.
  • Table - 必需。Table – Required. 要删除的记录表。A table of records to remove.
  • All - 可选。All – Optional. 在集合中,同一记录可能出现多次。In a collection, the same record may appear more than once. 添加 All 参数即可删除记录的所有副本。You can add the All argument to remove all copies of the record.

RemoveIf( DataSource, Condition [, ... ] )RemoveIf( DataSource, Condition [, ... ] )

  • DataSource – 必需。DataSource – Required. 数据源,其中包含要删除的一个或多个记录。The data source that contains the record or records that you want to remove.
  • Condition(s) - 必需。Condition(s) – Required. 一个公式,对于要删除的一个或多个记录,该公式的求值结果为 trueA formula that evaluates to true for the record or records to remove. 可以在公式中使用 DataSource 中的列名。You can use column names from the DataSource in the formula. 如果指定多个 Conditions ,则所有 Conditions 的求值结果都必须为 true,然后才能删除一个或多个记录。If you specify multiple Conditions, all must evaluate to true for the record or records to be removed.

示例Examples

在以下示例中,你将删除某个数据源中的一个或多个记录。该数据源名为 IceCream 且以下表中的数据开头:In these examples, you'll remove a record or records in a data source that's named IceCream and that starts with the data in this table:

公式Formula 说明Description 结果Result
Remove( IceCream,
First( Filter( IceCream, Flavor="Chocolate" ) ) )
Remove( IceCream,
First( Filter( IceCream, Flavor="Chocolate" ) ) )
从数据源中删除 Chocolate 记录。Removes the Chocolate record from the data source.

修改了 IceCream 数据源。The IceCream data source has been modified.
Remove( IceCream,
First( Filter( IceCream, Flavor="Chocolate" ) ) First( Filter( IceCream, Flavor="Strawberry" ) ) )
Remove( IceCream,
First( Filter( IceCream, Flavor="Chocolate" ) ) First( Filter( IceCream, Flavor="Strawberry" ) ) )
从数据源中删除两个记录。Removes two records from the data source.

修改了 IceCream 数据源。The IceCream data source has been modified.
RemoveIf( IceCream, Quantity > 150 )RemoveIf( IceCream, Quantity > 150 ) 删除其 Quantity 大于 150 的记录。Removes records that have a Quantity that's greater than 150.

修改了 IceCream 数据源。The IceCream data source has been modified.
RemoveIf( IceCream, Quantity > 150, Left( Flavor, 1 ) = "S" )RemoveIf( IceCream, Quantity > 150, Left( Flavor, 1 ) = "S" ) 删除其 Quantity 大于 150 且 FlavorS 开头的记录。Removes records that have a Quantity that's greater than 150 and Flavor starts with an S.


修改了 IceCream 数据源。The IceCream data source has been modified.
RemoveIf( IceCream, true )RemoveIf( IceCream, true ) 从数据源中删除所有记录。Removes all records from the data source.

修改了 IceCream 数据源。The IceCream data source has been modified.

分步操作Step by step

  1. 导入或创建名为 Inventory 的集合,让其显示在库中,如在库中显示数据所述。Import or create a collection named Inventory, and show it in a gallery as Show data in a gallery describes.
  2. 在库中,将图像的 OnSelect 属性设置为以下表达式:In the gallery, set the OnSelect property of the image to this expression:
    Remove(Inventory, ThisItem)Remove(Inventory, ThisItem)
  3. 按 F5,然后在库中选择图像。Press F5, and then select an image in the gallery.
    从库和集合中删除项。The item is removed from the gallery and the collection.