Power Apps Table vs Collection

In this Power Apps Tutorial, we will discuss the Power Apps table vs collection.

PowerApps is a low-code development platform that allows users to create custom applications without having to write code. One of the key features of PowerApps is the ability to work with data. Two ways to work with data in PowerApps are tables and collections.

By using Power Apps’ in-built Table() function and collect() function, we can build table and collection within the Power Apps. Below, we are going to discuss such topics:

  • Power Apps Table function
  • Create a table within the Power Apps
  • Power Apps collect function
  • Create a collection in Power Apps

Also, Read: Send formatted email using Power Apps HTML Text control

Power Apps Table function

The Power Apps Table function is a built-in function that allows you to create and manipulate tables of data in your app temporarily. It is a powerful tool for organizing and managing data in your app.

We can use the Power Apps Table() in a variety of ways, such as:

  • We can use the Table function to create a new table and define the columns and data types.
  • The Table function can be used to filter data from an existing table based on certain criteria.
  • By using the Power Apps Table(), we can sort the data in an existing table based on specific columns. Also, it allows grouping data from an existing table based on certain columns.
  • We can use the Table function to join two or more tables together based on common columns.
See also  Power Automate SharePoint Get Items Filter Query + 12 Examples

To build a table within the Power Apps, the following syntax is:

Table({Column1: value1, Column2: value2, ...})

In the above syntax, we can define the columns and their corresponding values for the table. The values can be constants, variables, or expressions.

Create a table within the Power Apps

Let’s build a table on the Power Apps and display the table using a Power Apps Data table control. For this, the following steps are:

  • On the Power Apps canvas app, add a Data table control.
  • Insert the below expression on the data table’s Items property.
Items = Table(
    {
        BookName: "Jane Eyre",
        Author: "Charlotte Brontë"
    },
    {
        BookName: "Moby Dick",
        Author: "Herman Melville"
    },
    {
        BookName: "Little Women",
        Author: "Louisa May Alcott"
    },
    {
        BookName: "Oliver Twist",
        Author: "Charles Dickens"
    },
    {
        BookName: "Dracula",
        Author: "Bram Stoker"
    },
    {
        BookName: "War and Peace",
        Author: "Leo Tolstoy"
    },
    {
        BookName: "Animal Farm",
        Author: "George Orwell"
    }
)

Where BookName and Autor are the names of the columns.

Create Table in Power Apps
Create Table in Power Apps
  • On the left side Properties panel, click on the Edit fields and add the fields to the Power Apps data table. Now the table will be appeared as below:
Create table using Power Apps table function
Create a table using Power Apps table function

This is how to use the Power Apps table function to create a table in Power Apps.

Check out: How to Display Dataverse Choices in Power Apps Gallery

Power Apps Collection

The Power Apps Collection function is a built-in function that allows us to create and manipulate collections of data within the app. Collections are temporary data storage areas that can be used to store data that is retrieved from a data source, generated by your app, or manipulated by your app.

See also  How to Filter a Power Apps Gallery With Multiple Dropdowns

The Collection function can be used in a variety of ways, such as:

  • By using the Collect () function, we can create a new collection and define the columns and data types.
  • We can use the AddColumns function to add columns to an existing collection and the Collect function to add rows to a collection.
  • The Filter() function is used to filter data from an existing collection based on certain criteria.
  • By using the Sort() function, we can sort the data in an existing collection based on specific columns.
  • In a Power Apps collection, we can use the GroupBy() function to group data from an existing collection based on certain columns. Also, we can use the Join() function, to join two or more collections together based on common columns.

To build a collection within the Power Apps, the following syntax is:

Collect(collectionname, {Column1: value1, Column2: value2, ...})

Create a collection within the Power Apps

Let’s build a collection within the Power Apps and display the collected data via a Power Apps data table or gallery. For this, the following steps are:

  • On the Power Apps screen, add the below expression on the screen’s OnVisible property to create a collection. As a result, the collection will be created when the screen will be visible.
OnVisible = Collect(
    CollBooks,
    {
        BookName: "Jane Eyre",
        Author: "Charlotte Brontë"
    },
    {
        BookName: "Moby Dick",
        Author: "Herman Melville"
    },
    {
        BookName: "Little Women",
        Author: "Louisa May Alcott"
    },
    {
        BookName: "Oliver Twist",
        Author: "Charles Dickens"
    },
    {
        BookName: "Dracula",
        Author: "Bram Stoker"
    },
    {
        BookName: "War and Peace",
        Author: "Leo Tolstoy"
    },
    {
        BookName: "Animal Farm",
        Author: "George Orwell"
    }
)

Where CollBooks is the name of the new collection. BookName and Author are the names of the collection’s columns.

Power Apps collection
Power Apps collection
  • Add a vertical gallery to the Power Apps screen and set the collection’s name in the gallery’s Items property.
Items = CollBooks
Create a collection on Power Apps
Create a collection of Power Apps

This is how to use the Power Apps collect function to create a collection.

See also  Countif function in Power BI Measure + 10 Useful Examples

Additionally, you may like some more Power Apps tutorials:

Conclusion

From the Power Apps tutorial, we learned how to create a table using the Power Apps table function and how to create a collection using Power Apps collect function.

  • >