ClearCollect Power Apps

ClearCollect is a function in Power apps that helps the user in clearing all the records from a file and then again storing the fresh records in the same file. Hence, the ClearCollect function is a combination that helps in performing two functions at a time which are first clear and then collect the data in the form of a table. In this article, we will talk about the collect and clear function in power apps, the creation of ClearCollect along with its uses and benefits. Then we will highlight the uses of power app functions and the method for clearing the collection inside a power app.

Collect and clear in Powerapps

Collect

The collect function in power apps is used for adding records. The clear function can have the following components in it:

  1. A single value: Single value is the value that is placed in the field present in a new record. Except for this field, the rest of the fields remain empty only. 
  2. A record: Every property with a particular name has a corresponding new record. Except for this, the remaining fields remain empty.
  3. A Table: A separate record of the data is created for every new record to be entered in the table. The table can never be present in the form of a nested table hence this can be reformed by wrapping the table present in the initial record.
  4. ClearCollect Function: The ClearCollect is a function in Power apps that performs the function of both collecting and clearing one by one. It helps the user in clearing all the records from a file and then again storing the fresh records in the same file

In case the data source is absent, a new collection gets formed that help in storing the global values sometimes. They can also form a duplicate copy of the data source that is temporary. There is another function called patch() that is used for creating records in the database. 

Below is the syntax for collect() function:

Collect( Data_Source, items_number , ... )

Where:

  • DataSource – This field is always required where the user inputs the data source that he wants to add. If the data doesn't already exist, then a new source is added to the collection. 
  • Item(s) - This field is always required where more than one record can be added to the table of the data source.

 Become a Powerapps Certified professional by learning this HKR Powerapps Training !

Powerapps Training

  • Master Your Craft
  • Lifetime LMS & Faculty Access
  • 24/7 online expert support
  • Real-world & Project Based Learning

Clear

The clear function helps in clearing all the records from the file or we can say it deleted all the records from the collection not clearing the columns of the fields.

The clear function is only operational on collections and it does not operate on the data sources.  There is a function called RemoveIf (Source_of_Data, true)that helps for the same purpose. This function tends to remove each and every record from the storage of the data source which in turn creates discrepancies in the records of other users. In that case, the user can use the Remove() function in case he wants to remove only a few records selectively. This function has no return value and hence can only be used in the behavior formula.

Below is the syntax for clear() function:

Clear(Collection)

Where:

Collection: This field is always required where the user can create a collection that he wants to create. 

CollectClear

ClearCollect is a function in Power apps that helps the user in clearing all the records from a file and then again storing the fresh records in the same file. Hence, the ClearCollect function is a combination that helps in performing two functions at a time which are first clear and then collect the data in the form of a table.

Below is the syntax for ClearCollect() function:

ClearCollect(Collection, item)

Where:

  • Collection: This field is always required where the user can clear the collection first and then add the required data to it. 
  • Item: This field is always required where the user can add more than one table or data source to the collection as per his requirement. 

Create and use the ClearCollect in powerapps

There are a few prerequisites for creating and using ClearCollect in power apps. They are:

  • A sign-up is mandatory for power apps followed by sign-in.
  • If the user has an app already then he can log in to the existing app otherwise he can create a new app. 
  • Configuration using the power apps. 
Let us see the steps below for using the ClearColeect in power apps:

1. The initial step is to add a Text input control. In case the user wants to rename it, he can click on the 3 dots present below the section and select rename then insert the product name of his choice. 

ClearColeect

2. The second step is to add a dropdown control. 

dropdown control

3. The drop-down can also be renamed as per the user’s wish. A user should always select the property as Items in the list. 

tems

4. The user now needs to replace the drop-down and add a button and add the property as Add to the text button. Let us do this with the expression below:

powerapps

5. ProductName column should be added with some text and color selection has to be done. Press Add

ProductName colum

6. The previous step has to be repeated 2 or more times.

7. The menu will finally look like this:

ProductList

Remove more than one item:

1. The user needs to select the template from the gallery by clicking at the gallery bottom. Then, click the pencil icon present in the up-left corner. Press trash and then choose.

Remove more than one item

2. Add (RemoveProductList,Item) by clicking OnSelect

3. There is a button clear for clearing the product list by using the function Clear(productList)

4. For removing an item, the item will be removed from the collection. 

 Want to know more about Powerapps,visit here Powerapps Tutorial !

Subscribe to our youtube channel to get new updates..!

Benefits of ClearCollect in Powerapps

  • It helps in quick and rapid app development.
  • It provides a seamless integration process with the 365 office tool
  • It has a universal Capitible User interface.
  • Multi-language support
  • It has offline capabilities for working.
  • It has very powerful data storage and management.
  • It has high efficiency and an app for optimization
  • It can integrate with 200+ integrators with a lot of systems.
  • It has a lot of flexible and automated systems with Microsoft workflow
  • It supports uninterrupted connectivity for hybrid systems

PowerApp Functions

There are a lot of powerApp functions listed below:

Related blog: What Is PowerApps

1. Color Functions 

  • Color: Sets a built-in color value.
  • ColorFade: This property fades the color value
  • ColorValue: It helps in the translation of CSS name or a hex code for specifying a color value
  • RGBA: it property returns the color value as green, red, or blue.

2. DataSource Functions 

  • DataSourceInfo: This property helps in providing information about the data source.
  • Defaults: This property helps in returning default values for the data source.
  • RecordInfo: It helps in providing information about a record.
  • Refresh: It helps in refreshing a record.
  • Revert: This property helps in reloading and clearing the record errors. 

3. Data and Time Functions 

  • Calendar: This property has information about the calendar for the locale.
  • Clock: This property has information about the clock regarding the locale.
  • Date: This property returns the date as well as time-based on the month or year. 
  • DateAdd:  This property can add data such as months, days, etc to the records.
  • DateDiff: This property helps in subtracting two date values the result is in the form of days or months. 
  • DateValue: This property converts the date into the date-time value.
  • Hour: It returns the hourly value
  • Month: It returns the monthly value
  • Now: It returns the current value of date and time.
  • Today: This property returns the current date value.

4. Error Functions

  • Error: This property contains the custom values for a data source.
  • Errors: This property provides all the error information between the data values.
  • IfError: This detects the error values providing an alternate value by taking appropriate action. 

5. Information Functions

  • IsBlank: This property checks for the empty or the black value.
  • IsEmpty: This property checks for the empty table.
  • IsMatch: This property matches the patterns with regular expressions.
  • IsNumeric: This property checks for the numeric value.
  • IsType: This property checks for the type of record reference
  • IsError: This property checks for the error value

6. Logical Functions

  • If: Checks if the value is true or not
  • And: Checks if all the values are true or not
  • Not: Checks if the argument is false
  • Or: Checks if one of the arguments is true
  • Match: Checks if the patterns match the regular expression

7. Math Functions

  • Abs: Checks for the absolute value of a numerical.
  • Exp: Checks for the raised value of a constant numerical.
  • Int: Checks for the rounding value of a numerical.
  • Ln: Checks for the natural log value
  • Log: Checks for the log value of a numerical.

8. Navigation Functions

  • Back: Checks for the previous screen
  • Exit: Checks for the currently running app
  • Navigate: Navigates to the changed screen

9. Offline Function

  • ClearData: This property clears the collection
  • LoadData: This property clears the collection from the app
  • SaveData: This property clears the collection of the app

10. ReadNFC: This property helps to read the NFC
11. Blank: This property helps to return the blank value for inserting a NULL value
12. Notify: This property helps in displaying the banner 

Top 30 frequently asked PowerApps Interview Questions !

Powerapps Training

Weekday / Weekend Batches

Clear a collection inside for all in PowerApps canvas apps

Let us assume there are a few unwanted records that the user does not want in his collection and he wants to remove them. Then he can make the use of PowerApp for performing this. If the user uses the remove() function, only a specific record is deleted from the collection. For choosing each item individually, the user needs to press the bin button again and again for clearing the data. After choosing, the user clicks on the submitted data, hence the item is removed from the collection. Other methods might remove all the items from the collection which is comparatively a risky thing to do. There are two main ways for removing the data from the collection:

Related blog: Powerapps Canvas

  • Remove a single item: A user needs to Select the PowerApp Gallery. then he needs to click on the icon in a pencil shape present in the up-left corner. He needs to follow the insert tab and then press the add button. As the button is renamed to delete, the user can easily delete the item by applying a property remove(details, item1).  
  • Remove all the items: A user needs to insert a button to delete the collection. Then add a property clear(Details) where details are the collection name. As the user presses this, the complete collection will be deleted. 
Conclusion

In this article, we have majorly discussed the 3 main functions which are collect(), clear() and CollectClear(). We have discussed the uses of all these 3 functions along with their syntax and uses. ClearCollect function is actually a combination that helps in performing two functions at a time which are first clear and then collect the data in the form of a table. Then we talked about the major CollectClear functions such as logical functions, numeric functions, color functions, data source functions, etc. last, we discussed the 2 main ways of deleting a collection. 

Related Blogs:

Find our upcoming Powerapps Training Online Classes

  • Batch starts on 29th Sep 2023, Fast Track batch

  • Batch starts on 3rd Oct 2023, Weekday batch

  • Batch starts on 7th Oct 2023, Weekend batch

Global Promotional Image
 

Categories

Request for more information

Amani
Amani
Research Analyst
As a content writer at HKR trainings, I deliver content on various technologies. I hold my graduation degree in Information technology. I am passionate about helping people understand technology-related content through my easily digestible content. My writings include Data Science, Machine Learning, Artificial Intelligence, Python, Salesforce, Servicenow and etc.

This is performed using the clear() function.

The collections have a function called collect() that helps in adding a record to the list.

The collections are stored in the menu under the file-> collections tab.

Collections have a size of about 2000 records.

Clear: The clear function helps in clearing all the records from the file or we can say it deleted all the records from the collection not clearing the columns of the fields.

CollectClear: ClearCollect is a function in Power apps that helps the user in clearing all the records from a file and then again storing the fresh records in the same file.

The variables are very similar to data sources. They contain a number of records of each file.

This is performed using the edit option in the gallery of the PowerApp which is located on the right side of the page.