Click here to Skip to main content
15,173,640 members
Articles / All Topics
Technical Blog
Posted 29 Apr 2018

Tagged as


1 bookmarked

What is Collection & How to Manage a Collection in PowerApps ?

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
29 Apr 2018CPOL3 min read
What is collection & how to manage it in PowerApps?

In the last article, we learned about the different controls which exist in PowerApps although there are some more controls which we will discuss going forward. Before jumping into remaining controls, let’s discuss here the most important part Collection.

What is Collection?

A collection is used to store data that can be used in your app or we can say a collection is a group of items that are similar. For example, Student data collection where the collection will store student first name, last name and other information about the student.

To see it practically, let’s open PowerApps editor and add a new screen and OnStart function to create a collection.

Now to create a collection in PowerApps, we have  “Collection” function in PowerApp and syntax is as follows: 

Collect(Collectionname, items)

So, Student collection can be defined as follows:

Collect(StudentCollection,      {Name:"Rajat",LastName:"Jaiswal"},   {Name:"Sandeep",LastName:"Jain"})


So, we have created our first collection. To view this in action, add any control you want. Here, we are using Gallery control.


Once you added this control, you will find the data properties and we can see our created collection which is “StudentCollection”.


Here, we can assign  the title and subtitle  properties of the gallery with the property Name & LastName of our new StudentCollection. Just save the application at this point and reload the app again.

You will find the following screen:


We can check our newly created collection by file option as shown below:


In this way, we can create a collection. Now, the next question is how to ADD/EDIT/Remove in the collection. So, let’s understand this now.

Add Collection

Just drag-drop textboxes, labels, and a button to add the data to the collection as shown below. On Add button onSelect, write the below function:


Now, when you run and click on Add button. You can see the Record appears in your gallery as shown in below figure:

Collection Add

Remove Collection

Now, in the next step, we will delete the record from the collection.

The syntax of this is very simple:

Remove (CollectionName,item)

Now, to achieve this, add a delete icon in the gallery as shown in the below figure:


On select of delete icon, we can write Remove(StudentCollection, This.Item).

Here, This.Item is selected item of the gallery to which we need to delete from the collection.

Now, what if we want to delete the entire collection? Then in such case, we have:

Clear Collection

The syntax is very simple Clear(CollectionName)

So in our case, we have to write Clear(StudentCollection)

Now, to Edit a particular item in a collection, the first thing is to select the item in the text box which we want to edit and to achieve this, we bind the textbox by Gallery’s selected item as shown in the below figure:


Once you are done with this, then on Update button, we can write Patch collection function as shown below:


So the syntax is very simple.

Patch(StudentCollection,Gallery1.SelectedItem, {Name:TextInput4.Text,LastName:TextInput5.Text})

So in this way, we can update the specific item (as shown above, we updated only selected item from Gallery).

So, in this session, we understood Collection, add an item in the collection, Remove function to remove a specific item from the collection, Clear Collection to delete entire items from the collection and none other than Patch function to edit the collection.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Team Leader
India India
I am Rajat Jaiswal from India. I am working as a Technology specialist in one of the reputed company in India with 12+ years of experience. I am a Microsoft Data Platform MVP & Alibaba Cloud MVP.
I have always had an affinity to learn something new in technology. Database, Web development, Cloud computing are the areas of my interests always.
I have been a regular contributor to technologies with more than 300+ tips. Learning & Sharing is one of my aims always. Writing blogs, delivering sessions, helping on forums is my hobby.

Comments and Discussions

QuestionHow to iterate in collection one by one? Pin
Member 135718615-Aug-18 23:35
MemberMember 135718615-Aug-18 23:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.