Create Collection in Power Apps

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.

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).

powerapps create collection

Power Apps Collection Syntax

To create 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:

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.

How to Create Collection in Power Apps

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 powerapps

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

collection in powerapps

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 powerapps

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

powerapps create collection

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.

how to create a collection in powerapps

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].

how to create collection in powerapps

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.

power apps create collection

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

collections in powerapps

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 a collection powerapps

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

create a collection in powerapps

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 to 500 items, but not much more.

How to Overcome Power Apps Collection Items Limit

To overcome this type of Power 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.
powerapps collect function
  • This method also has one drawback. This method can allow only a maximum of 2,000 items or values but not more than that. You can only add 1-2000 numbers in the Value field because Power Apps does not know about the 2001 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 on Import from Excel.
  3. Select Excel file -> Choose a table that you want to import
PowerApps Collection Item Limit

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:

  • Thank you Bijay for the detailed explanation.
    I couldn’t find why we need a button with “OnSelect” instead of a screen with “OnVisible=”

  • Hello,
    i have a sharepoint list wherein a column has repetitive value in string datatype
    i need a collection using group by count and raw of that particular column
    for example-
    SAPnumber Status
    234 Open
    345 Close
    234 Open
    435 Close
    654 Open
    756 on-going
    457 open

    output in collect-
    status value
    open 4
    close 2
    ongoing 1

    Please help in this request

  • >