<img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=931099456970389&amp;ev=PageView&amp;noscript=1">

powerappslogoDo you know how to use collections in PowerApps? Collections are an array that you store in memory in PowerApps and can be used in many ways. In this tutorial, I’ll cover how to create and use collections.

Collections can be used to: keep data or take data offline, to manipulate data and batch it up to your data source of choice, SQL Server for instance. In my demo, I’ll use some basic collections to view some different functions we can use:

  • Collect: this function is used to retrieve the data and put it into a collection
  • Clear: used to clear the collection
  • Patch: used to update the collection
  • Clear/Collect: used to do the same thing at the same time

Be sure to watch my video demo included here, but here’s a brief synopsis of what I’ll cover in my walk through:

  • I begin with a basic app of a Customer Sales Chart and I’ll start by creating a few labels for Product and Quantity.
  • Next, I’ll add two inputs (one for Product and one for Quantity) by clicking on Text and the Text Input; this is what we’re going to pass data into.
  • Then I’ll create a button to inject that new row into the collection.
  • There are a couple of ways we can create our collection:
    • Collect function: will basically create the collection and starts to inject the first set of rows into it.
    • Clear/Collect: if there’s anything in that collection, it will wipe it clean and load it up again. I’ve only had to use this option for very localized things like maybe starting up an app, for example, where there might be something in that collection from a previous setting.
  • In this case, I’ll use the collect function. I go into the code bar and type in collect and the great thing here is it will start to write the code for us, and you’ll see what the next step is which is basically the column name and then where input of that product or quantity information is.
  • Once I’ve created my first collection, I try to inject a row; I type in a value in my product field (basketballs for instance) and quantity value and click the collect button.
  • To see my results, I can go to File and Collections and I can see my rows to debug. I’ll show you how to create a Gallery so I can start to use this collection. In the Gallery it will treat my collection like any other database table where I can remove and edit rows in the collection.
  • The final step I’ll show is how to edit, as well as patch, the collection.

Check out my video demo included here to learn step by step basics of collections in PowerApps including how to inject rows, clear rows and update rows in a collection using commands. It gets much more interesting as we start to go offline with these collections.

Keep an eye out for more of my PowerApps tutorial posts and if you want to learn PowerApps in depth, our PowerApps courses in our On-Demand Learning platform will take a deep dive into all you need to know. Visit our website to learn more or click the link below for your free trial of our learning platform with 50+ courses taught by industry experts and taken at your pace.

On-Demand Training
bg-img14.jpg

Join Our Blog

Join thousands of other SQL Server, BI and cloud pros by subscribing to our blog.

Leave a comment

Posts by Topic

see all

Recent Articles

Popular Articles