Create Collection in Power Apps - SPGuides (2024)

Create Collection in Power Apps - SPGuides (1)

Are you wondering how to create a collection in Power Apps? No need to worry!

In this Power Apps tutorial, I will explain everything about the Power Apps Collection, like what is a collection in Power Apps and its syntaxes.

Also, we will see how to create a collection in Power Apps manually as well from the SharePoint list.

Moreover, I will show you how to create a collection using button control and the item limitations in Power Apps collection using various scenarios.

Table of Contents

Collection in Power Apps

A Collection means a group of items or an Array. A Power Apps Collection is an array that helps store the data in Powerapps memory. Later, You can use these stored data in many ways.

Additionally, data from any data source—such as an Excel spreadsheet or a SharePoint Online list—can be saved in a Power Apps Collection.

By default, 500 rows is the maximum number of rows that can be imported into a collection simultaneously. You can increase this to 2,000 by increasing the delegation limit.

You can create a PowerApps Collection on OnStart of the App so that the code will run each time the app loads. Also, you can use a PowerApps Button control (on Button’s OnSelect property).

Create Collection in Power Apps - SPGuides (2)

Power Apps Collection Syntax

Tocreate a Power Apps Collection, follow the syntaxes below:

Syntax – 1: [Using Power Apps Collect Function]

Collect(CollectionName, record(s))

Where,

  • Collect= Power Apps Collect function helps add records to a data source
  • CollectionName= You need to specify a collection name while creating the Powerapps Collection
  • record(s)= The Record we can take as a single value, an item, or a table.

Syntax – 2: [Using Power Apps ClearCollect Function]

ClearCollect(CollectionName, record(s))

Where,

  • ClearCollect = Power Apps ClearCollect function deletes all the records from a collection. And then adds a different set of records to the same collection.

How to Create Collection in Power Apps

Now we will see how to create a Power Apps Collection with different approaches like:

  • Create a Collection in Power Apps [Manually]
  • Create a Collection in Power Apps from a SharePoint List

Let’s explore one by one.

Create Collection in Power Apps [Manually]

Assuming we have a list of books we would like to add to a collection. I will create this collection on the App’s OnStart property.

To create a collection in Power Apps, follow the instructions below:

1. Sign in to Power Apps with valid Microsoft credentials.

2. Create a Blank Canvas app [+ Create -> Blank app -> Click Create under the Blank canvas app].

3. Provide the App name and choose any Format [Tablet/Phone]. Click on Create.

Create Collection in Power Apps - SPGuides (3)

4. Go to the App’s OnStart property and write the code below:

OnStart = Collect( BookCollection, { BookName: "The Testaments", Author: "Margaret Atwood" }, { BookName: "Cheque book", Author: "Vasdev Mohi" }, { BookName: "The Overstory", Author: "Richard Powers" }, { BookName: "Come! Let's Run", Author: "Ma. Subramanian" }, { BookName: "Spare", Author: "J. R. Moehringer" })

Where,

  • BookCollection = Collection Name
  • BookName, Author = Collection Headers/Columns
  • “The Testaments”, “Margaret Atwood” and so on = Collection Items/Records

NOTE:

Also, you can use ClearCollect function instead of using Collect function. All that needs to be changed in the code above is to use the ClearCollect function in place of the Collect function.
Create Collection in Power Apps - SPGuides (4)

5. Save and Publish the app. Click on Publish this version. Also, run the App [App -> Ellipses … -> Run OnStart] as shown below.

Create Collection in Power Apps - SPGuides (5)

6. Now, the collection has been created. To view the result, go to Variables [x] -> Expand Collections -> Select ellipses of specific collection [BookCollection] -> View Table.

Create Collection in Power Apps - SPGuides (6)

7. The specific collection will appear with all the records, like the image below.

Create Collection in Power Apps - SPGuides (7)

This is how to create a collection in Power Apps manually.

Power Apps Create Collection Using Button

Next, we will explore creating a Power Apps Collection using a Button control.

The screenshot below represents custom controls and a Button. A user will fill in the fields and click on the CREATE button.

Once he/she taps the button, the collection will be created and saved in the Power Apps Variables section.

Create Collection in Power Apps - SPGuides (8)

To achieve this, follow the instructions below:

1. On the Power Apps screen, add some controls like Text labels, Text inputs, a Dropdown, and a Button. Just rename all the controls from the Tree view.

2. Rename the button as CREATE [by double tapping].

Create Collection in Power Apps - SPGuides (9)

3. Select the Button input and set its OnSelect property to the code below:

OnSelect = ClearCollect( colEmployeeDetails, { empName: txtEmpName.Text, empId: txtEmpID.Text, empRole: ddJobRole.Selected.Value, empAddress: txtAddress.Text })

Where,

  • colEmployeeDetails = Collection Name
  • empName, empID, empRole, empAddress = Collection Headers/Columns
  • tctEmpName, txtEmpID = Text input control names
  • ddJobRole = Dropdown control name
  • txtAddress = Text input control name [Multi-text]

Refer to the image below.

Create Collection in Power Apps - SPGuides (10)

4. Save, Publish, and Preview the app. Enter all the employee details and click on the CREATE button.

Create Collection in Power Apps - SPGuides (11)

5. Now, the new employee collection has been created. To view the result, go back to the Power Apps screen -> Select Variables [x] -> Expand Collections -> Select ellipses of the specific collection [colEmployeeDetails] -> View Table.

Create Collection in Power Apps - SPGuides (12)

6. The new item has been displayed in the collection, like the image below.

Create Collection in Power Apps - SPGuides (13)

This way, we can create a Power Apps Collection using Button control.

Power Apps Collection Items Limit

  • In the Powerapps, items are limited in every data source like SharePoint, OneDrive, Common Data Service, etc.
  • You can only add 500 items from a data source, but not more than that. If you will add more than 500, then the PowerApps won’t allow adding.
  • Let’s take an example. Suppose you have 550-600 items in an Excel file on your OneDrive for Business. Adding this data source into the app will allow only up to500items, but not much more.

How to Overcome Power Apps Collection Items Limit

To overcome this type ofPower apps Items limit, you need to do some below things:

  1. Increase the total Item Limit in PowerApps App Settings:
  • You can extend your Power Apps item limits above 500 using this method below.
  • Go to Settings (… -> Settings) -> General -> Set Data row limit as 2000 as below.
Create Collection in Power Apps - SPGuides (14)
  • This method also has one drawback. This method can allow only a maximum of2,000items or values but not more than that. You can only add1-2000numbers in theValuefield because Power Apps does not know about the2001 item.
  • So, if more than 2000 items are in your Excel file, this method will not work. For that, you can use this below the second method.

Use Static Data:

  • The best solution for this item limit case is to use static data. There will be 10,000 rows in this method, and you can access all rows.
  • In this case, You need to import the static data instead of using SQL Database, where you must spend extra money.
  • These static data are attached to your app where there may be an effect on the app loading time due to enlarging the total size.
  • You can add the Static data by using the below steps:
  1. View->Data Sources-> Search the data source like Excel
  2. Click onImport from Excel.
  3. Select Excel file -> Choose a table that you want to import
Create Collection in Power Apps - SPGuides (15)

If this method does not fulfill your needs, then remember one thing, Excel is a good method but you have to modify it from within the app.

3. OneDrive for Business Connectors:

  • Suppose you need more than 2000 rows stored in one data source, then you should switch from OneDrive for Business data source to any other data source like SQL, Common Data Service, SharePoint, etc.
  • In this method, you can’t get more than 2000 rows.
  • The OneDrive for Business connector has a separate connection to each table in the Excel file. The item limit of 2000 value is related only to the connections but not the source.

These are the item limitations in the Power Apps Collection.

Conclusion

I hope you got the details about the Power Apps Collection, like what it means by Power Apps Collection and its syntaxes.

Additionally, we learned how to manually create a collection in Power Apps from the SharePoint list.

Moreover, I explained how to create a collection using button control and the item limitations in the Power Apps collection using different examples.

Also, you may like some more Power Apps tutorials:

  • Power Apps Collection Distinct Filter
  • Add Image to a Power Apps Collection
  • Create Empty Collection in Power Apps
  • Add Gallery Data to a Collection in Power Apps

Create Collection in Power Apps - SPGuides (16)

Bijay Kumar

I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have more than 17 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com

Create Collection in Power Apps - SPGuides (2024)
Top Articles
Latest Posts
Article information

Author: Msgr. Refugio Daniel

Last Updated:

Views: 5796

Rating: 4.3 / 5 (74 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Msgr. Refugio Daniel

Birthday: 1999-09-15

Address: 8416 Beatty Center, Derekfort, VA 72092-0500

Phone: +6838967160603

Job: Mining Executive

Hobby: Woodworking, Knitting, Fishing, Coffee roasting, Kayaking, Horseback riding, Kite flying

Introduction: My name is Msgr. Refugio Daniel, I am a fine, precious, encouraging, calm, glamorous, vivacious, friendly person who loves writing and wants to share my knowledge and understanding with you.