A Basic Guide to Creating and Using Collections in PowerApps

Topics: Power Apps, PowerApps

Written by Quentin Russell

Building collections in PowerApps is a great way to keep data, take it offline, manipulate data and batch it up to your data source of choice. For example, your company can use a PowerApps collection to store employee information and organize them by their names, positions, departments, and any other information you would like to use. Once you've collected this data together, you can use it in a variety of ways to facilitate your organization's work. So, with that said, let's take a look at what you need to do in order to begin using a PowerApps collection. 

How to Create a Multicolumn Collection

  • In Power Apps Studio, add a Text input control.
  • Rename the control by selecting the ellipses in the left navigation pane, clicking Rename, and then typing ProductName.
  • Add a Drop down control.
  • Rename the Drop down control Colors, and then make sure that the Items property is selected in the property list.
  • In the formula bar, replace DropDownSample with this expression:
    1. ["Red", "Green", "Blue"]
  • Add a Button control, set its Text property to "Add", and set its OnSelect property to the following formula:
  • Collect(       Productlist,
           {
                    Product:  ProductName.Text,
                    Color:  Colors.Selected.Value
            }
      )
  • Press F5 on your keyboard, type text into ProductName, select an option in Colors, and then click Add.
  • Repeat the previous step at least two more times and then press Esc on your keyboard.
  • On the File menu, select Collections to show the collection that you created.

Now that you've done that, let's take a look at the steps you need to follow in order to show a collection and see that it's working. 

Show a Collection

  1. Add a vertical Gallery control. 
  2. Set the gallery's Items property to ProductList.
  3. In the Data pane, set the subtitle field to Color, and set the title field to Product.
  4. Close the Data pane, select the gallery, and then set the Layout field to Title and subtitle.

You may find that the data you've added is wrong or it is unnecessary to track. If you find yourself in this situation, you'll need to be able to remove that information from your collection. Let's take a look at what you need to do in order to remove an item from your PowerApps collection. 

Remove One or All Items

  1. Select the gallery template by clicking or tapping near the bottom of the gallery and then clicking/tapping the pencil icon near the upper-left corner.
  2. Add a Trash icon to the gallery template. 
  3. Set the icon's OnSelect property to this formula:
    • Remove(ProductList,  ThisItem)
  4. Outside the gallery, add a button, set its Text property to "Clear", and set its OnSelect property to this formula:
    • Clear(ProductList)
  5. While holding down the Alt key on your keyboard, select the Trash icon for an item to remove the item from the collection, or select the Clear button to remove all items from the collection.

While you can work just with PowerApps, you also have the power to connect it to other Microsoft platforms. One great thing you can do is connect it to SharePoint. By connecting a SharePoint list to PowerApps, you can automatically port over the information you need to organize and use without having to transfer it manually. So, with that in mind, let's take a look at the steps you need to follow to create a connection with a SharePoint list. 

E-book cta - SHAREPOINT TRICKS THAT NO ONE WILL TELL YOU

How to Create a Connection to a SharePoint List

  1. Sign into PowerApps, select Data, then Connections in the left navigation bar and then select New connection in the upper left corner.
  2. In the search box near the upper-right corner, type or paste SharePoint, and then select SharePoint.
  3. Perform either of these sets of steps:
    1. To connect to SharePoint Online, select Connect directly (cloud services), select Create, and then provide credentials (if prompted). The connection is created, and you can add a data to an existing app or build an app from scratch.
    2. To connect to an on-premises site, select Connect using on-premises data gateway. Specify Windows as the authentication type, and then specify your credentials. (If your credentials include a domain name, specify it as domain\alias.). Under Choose a gateway, select the gateway that you want to use, and then select Create. The connection is created, and you can add a data to an existing app or build an app from scratch.

Now that you've created a connection between your SharePoint list and PowerApps, it's time to put that list into the collection you want to use. Let's take a look at the steps you need to follow in order to do that. 

Put a SharePoint List Into a Collection

  1. Make sure you have connected a SharePoint list to PowerApps as explained above.
  2. Add a button, and set its OnSelect property to the following function, replacing ListName with the name of your SharePoint list:
    • Collect(MySPCollection,  ListName) 
    • This creates a collection names MySPCollection and that contains the same data as your SharePoint list.
  3. While holding the Alt key on your keyboard, select the button.
  4. To preview the collection you've created, select Collections on the File menu (This is optional).

Conclusion

By following the instructions we've laid out, you should be ready to get started with the basics of creating and using collections in PowerApps. Now that you know the essentials, you should be ready to start learning the more advanced tools that PowerApps has to offer. Be sure to subscribe to Dock 365's blog and check back everyday for more tutorials on how to use Microsoft's wide array of productivity tools.

Comments:
office365-productivity2
Book a Free Demo Now!

Don't Get Left Behind!
Subscribe to Dock 365 Blogs!
Stay up to date with the latest business tips and trends.