Vijender Kotagiri
What is Collect, Clear, and ClearCollect functions in Power Apps

Collect:

The Collect function adds records to a data source. The items to be added can be:

A single value: The value is placed in the Value field of a new record. All other properties are left blank.
A record: Each named property is placed in the corresponding property of a new record. All other properties are left blank.
A table: Each record of the table is added as a separate record of the data source as described above. The table isn’t added as a nested table to a record. To do this, wrap the table in a record first.
When used with a collection, additional columns will be created as needed. The columns for other data sources are fixed by the data source and new columns can’t be added.

If the data source doesn’t already exist, a collection is created.

You can also use the Patch function to create records in a data source.

Collect returns the modified data source as a table. Collect can only be used in a behavior formula.

Clear:

The Clear function deletes all the records of a collection. The columns of the collection will remain.

Note that Clear only operates on collections and not other data sources. You can use RemoveIf( DataSource, true ) for this purpose. Use caution as this will remove all records from the data source’s storage and can affect other users.

You can use the Remove function to selectively remove records.

Clear has no return value. It can only be used in a behavior formula.

ClearCollect
The ClearCollect function deletes all the records from a collection. And then adds a different set of records to the same collection. With a single function, ClearCollect offers the combination of Clear and then Collect.

ClearCollect returns the modified collection as a table. ClearCollect can only be used in a behavior formula.

By Vijender Kotagiri in Power Apps on Mar 19 2023
  • Rajkiran Swain
    Apr, 2023 3

    In Power Apps, Collect, Clear, and ClearCollect functions are used to manipulate data in collections. Here is a brief explanation of each function:Collect: The Collect function is used to create a new collection or add data to an existing collection. Clear: The Clear function is used to remove all items from a collection. ClearCollect: The ClearCollect function is used to remove all items from an existing collection and add new items to it.

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS