How to Create a Power Apps Collection On OnStart Property?

This Power Apps tutorial explains how to create a Power Apps collection on OnStart property.

Here, I will describe Power Apps Collection OnStart, and I will also show you every step of how to create a Power Apps Collection OnStart manually.

Additionally, we will see how to create a Power Apps Collection using a SharePoint list and Excel. At last, we will see how to sort a Power Apps collection alphabetically either in ascending or descending order.

Power Apps OnStart Property

The Power Apps OnStart Property runs when the user starts a Power Apps app. The OnStart property allows the user to get and store data in the collection by using the collect function.

How to Create a Power Apps Collection On OnStart Property

Here, I will show you how to create a Power Apps collection OnStart using two ways:

  1. Create a collection OnStart of a Power Apps manually [without any data source]
  2. Create a collection OnStart of a Power Apps using the SharePoint list

Create Power Apps Collection Manually

Here, I will show you how to create a Power Apps collection OnStart using the data manually.

I have a Power Apps canvas app related to furniture delivery. The app has a gallery control; when the user OnStarts an app, it displays the furniture arriving soon.

Create a Power Apps Collection OnStart manually

Follow the below steps to achieve this:

  • Create a Power Apps blank canvas app.
  • Insert two image controls of the furniture on the screen and turn off the visible properties of both images.
How to create Power Apps canvas app Collection using OnStart property
  • In the Tree view, Click on the App [left-hand side] -> Select the OnStart property and apply the code below:
OnStart = 
  Collect(
    colNewlyFurinitureArrived,
    {
        Furniture: "Nest Sofa",
        'Arriving Date': "08/09/2023",
        Image: Sofa
    },
    {
        Furniture: "Dining Table",
        'Arriving Date': "11/09/2023",
        Image: 'Dining Table'
    }
)

Where,

  1. Collect:- Collection function name.
  2. colNewlyFurinitureArrived:- Provide your collection name.
  3. Furniture, Arriving Date, Image: These are the columns where the new types of furniture, arriving date, and image will be stored.
Create Power Apps canvas app Collection OnStart
  • Click on the App, select the More options (…) -> Then click on Run OnStart
Create a Power Apps canvas app Collection OnStart
  • On the left-hand side, click on the Variables (x) -> Expand the Collections -> Then select the Collection name, click on the More options (…) -> Then click on View Table.
Create a Power Apps Collection OnStart
  • We can see that the Power Apps collection will be created without using any data source.
How to create a Power Apps Collection OnStart

Now, we will display the Power Apps collection using a Flexible height gallery control.

  • Insert the Flexible height Gallery, select the Items property, and then provide the code as the collection name:
Items = colNewlyFurinitureArrived

Where,

  • colNewlyFurinitureArrived: Created Power Apps collection name
How to create a Power Apps canvas app Collection OnStart
  • Now, the gallery control will be connected to a created Power Apps collection as shown below:
Power Apps canvas app create a Collection OnStart

This is how to manually create a Power Apps Collection OnStart [without using any data source].

Create Power Apps Collection Using SharePoint List

Here, I will show you how to create a Power Apps collection OnStart using a SharePoint list.

I have a SharePoint Online list regarding [iPhone Offers], which has different fields like:

Fields NameData Type
iPhone IDTitle
ModelsChoice [iPhone 14pro Max, iPhone 14, iPhone 13, iPhone 12, iPhone SE]
PriceCurrency
OfferSingle line of text
iPhone ImageImage
Offer Closes byDate and time
Create Power Apps Collection OnStart

Using that SharePoint list, we will create a Power Apps collection using the OnStart property.

  • Create a Power Apps blank canvas app.
  • Click on the Connect to data from the middle of the Screen page -> A dialogue box will appear [left-hand side], Click on the Add data.
Create an Power Apps Collection OnStart
  • Now expand Connectors. Select the data source as SharePoint, then select a SharePoint site to which you want to connect.
Create a Power Apps Collection OnStart using SharePoint list
  • Now, select the SharePoint list, Then click on the Connect button. Now, the SharePoint list will be connected to a Power Apps canvas app.
Create an Power Apps Collection using OnStart property
How to create the Power Apps Collection OnStart
  • In the Tree view, Click on the App [left-hand side] -> Select the OnStart property -> Then apply the SharePoint list collection formula.
OnStart = Collect(coliPhoneOffers,'iPhone Offers')

Where,

  1. coliPhoneOffers: Provide your Collection name.
  2. iPhoneOffers: SharePoint list name.
Create the Power Apps Collection OnStart
  • Click on the App, select the More options (…) -> Then click on Run OnStart
Create the Power Apps Collection using the OnStart property
  • On the left-hand side, click on the Variables (x) -> Expand the Collections -> Then select the Collection name, click on the More options (…) -> Then click on View Table.
How to create an Power Apps Collection using OnStart property
  • Now, we can see that the Power Apps collection will be created from a SharePoint list as shown below:
Power Apps create Collection using OnStart property

Now, we will display the Power Apps collection from a SharePoint list using horizontal gallery control.

  • Insert the Horizontal Gallery, Select the Items property, and then provide the code as the collection name:
Items = 'iPhone Offers'

Where,

iPhone Offers: Created Power Apps collection name

Create the Power Apps canvas app Collection OnStart
  • Change the Layout section:
Layout = Tile and subtitle on overlay
  • Now the gallery control looks like the below image:
Power Apps create Collection OnStart property
  • Click on the Offer field -> In the Properties pane, change the Color property to black and the Fill property to green as shown below:
How to create Power Apps canvas app Collection OnStart

When the user opens or runs the app, they should receive an iPhone offer which are available as shown below:

Power Apps canvas app Collection using OnStart property

We can create a Power Apps collection using the SharePoint list as a data source by app OnStart property.

How to Create a Power Apps Collection From Excel

Here are the steps to create a Power Apps Collection from Excel.

  1. Format an Excel sheet as a table.
  2. Create a blank canvas app in Power Apps.
  3. Connect a data source to Import from Excel.
  4. Create a Power Apps app collection from Excel.

Step 1: Format an Excel sheet as a table

I have an Excel file regarding ‘Doctor Details,’ which has fields like:

Field NameData Type
DoctorNameSingle line of text
DoctorEmailHyperlink
SpecializedInChoice
YearsOfExperienceSingle line of text
ConsultDoneNumber
Power Apps Collection From Excel

We will create a Power Apps Collection using the above Excel sheet. But we can see that our Excel sheet is not formatted as a table if we try to connect an Excel sheet as a data source without formatting.

We will receive an error: “No tables found in the Excel file. Only tabbed data is currently supported by the importer”.

Create an Power Apps collection using an excel

So, 1st, format your Excel sheet into a table format using “Format as Table.”

Power Apps Collection From Excel table
  • Then, change the Excel table name, Select a table, and Click on the Table Design tab [upper right-hand side] -> Then, Rename the table name based on your requirement and save the Excel file.
How to create Power Apps collection from excel file

Step 2: Create a blank canvas app in Power Apps

Now, we will create a blank canvas app in Power Apps :

  • Go to the Power Apps Home page -> Select the Apps section [Right-hand side] -> Expand the +New app -> Then click on the Canvas app.
Create Power Apps collection from an Excel
  • Now a dialogue box will open as “Canvas app from blank” and provide the app name based on your requirement -> Then select the Format as Tablet -> Click on the Create button.
How to create Power Apps collection from Excel
  • Now, the Power Apps app will be created with a new screen, as shown below:
Create Power Apps collection from Excel file

Now, we have created a blank canvas app in Power Apps. The next step is to connect to the Excel data.

Step 3: Connect an Excel sheet as a Data Source in Power Apps

Now, we will connect a data source to an Excel to work on the Collection.

  • Click on the Connect to data from the middle of the Screen page -> A dialogue box will appear [left-hand side]; click on the Add data.
Create Power Apps collection from Excel table
  • Now Select a data source by expanding the Connectors -> Then click on the See all connectors -> Select the data source as Import from Excel.
How to create collection from Excel using Power Apps
  • Now, select an Excel file from your local device.
How to create Power Apps canvas app collection from Excel
  • A dialogue box will appear as “Choose a Table.” Select the data table -> Then click on the Connect button.
Create Power Apps canvas app collection from Excel file
  • The Excel table will now be connected to our Power Apps canvas app.
Power Apps create collection from Excel

Moving forward, our next step involves creating a Power Apps app collection from Excel.

Step 4: Create a Power Apps app collection from Excel

We will create a Power Apps collection from Excel using the App OnStart property by applying the Excel collection formula.

  • In the Tree view, Click on the App [left-hand side] -> Select the OnStart property -> Then apply the Excel collection formula.
Collect(colDoctorDetails, DoctorDetails)

Where,

  1. Collect: Collection function name.
  2. colDoctorDetails: Provide your Collection name.
  3. DoctorDetails: Excel sheet table name.
Power Apps create a collection from an Excel
  • Now, we will Run OnStart, to create a collection from an Excel file. On the App, click on the More options (…) -> Then select Run OnStart
Power Apps collection from Excel sheet

Now, let us check if the collection will be created from an Excel table or what?

  • On the left-hand side, click on the Variables (x) -> Expand the Collections -> Then select the Collection name, click on the More options (…) -> Then click on View Table
Power Apps create collection from the Excel file
  • Now, we can see that the Power Apps collection will be created from an Excel file, as shown below:
Power Apps create a collection from an Excel table

Per the above steps, I have shown you how to create a PowerApps collection using an Excel table. In my Excel table, we can see that there are only 6 fields.

However, you may required to retrieve only three specific columns from an Excel table to create a Power Apps collection; let me show you how to create it with each step.

Create a Power Apps collection by retrieving specific columns from an Excel table

You can retrieve only the specific columns from an Excel table while creating a Power Apps collection. Follow the below steps to achieve it:

  • After connecting a data source to Import from Excel to a Power Apps screen.
  • On the Tree view, Click on the App [left-hand side] -> Select the OnStart property -> Then apply the Excel collection formula.
ClearCollect(colDoctorDetails,ShowColumns(DoctorDetails,"DoctorName","DoctorEmail","SpecializedIn"));

Where,

  1. ClearCollect: This function helps to remove duplicate data and adds new data to the same Power Apps collection.
  2. colDoctorDetails: Provide your Collection name.
  3. ShowColumns: This function helps to show the columns of a table or a list.
  4. DoctorDetails: Excel sheet table name.

Then, provide the specific column names based on your requirements.

How to create a Power Apps collection by retrieving specific columns from an Excel table
  • Now, we will Run OnStart to create a collection from an Excel file. On the App, click on the More options (…) -> Then select Run OnStart.

Now, let us check that the collection will be created by retrieving specific columns from an Excel table.

  • On the left-hand side, click on the Variables (x) -> Expand the Collections -> Then select the Collection name, click on the More options (…) -> Then click on View Table
  • Now, we can see that the Power Apps collection will be created by retrieving three specific columns from an Excel table, as shown below:
Create a Power Apps collection by retrieving specific columns from an Excel table

This is how we can retrieve specific columns from an Excel table to create a Power Apps collection.

Power Apps Sort Collection By Descending [Z-A]

Next, I will show you how to sort a Power Apps collection in descending order.

Example:

  1. I will also take the same Power Apps collection [colEventRegistration] for this example.
  2. In Power Apps, there is a Data table control. This data table will sort and display each record from the Power Apps collection based on the “Name” column in descending order.
Power Apps Sort Collection By Descending

To work around this example, follow the below steps:

3. On the Power Apps Screen -> Insert a Data table and set its Items property as:

Items = SortByColumns(
    colEventRegistration,
    "Name",
    SortOrder.Descending
)

Where,

  • SortByColumns() = This function is also used to sort the table depending on the formula
  • “Name” = Power Apps Collection Column Field
  • SortOrder.Descending = Descending order of the Power Apps collection based on the “Name” column [For ascending, you can add SortOrder.Ascending]
Sort Power Apps Collection By Descending

4. Run OnStart, Save, Publish, and Preview the app. The data table displays the sorted records [Event Registration Records] based on the based on “Name” column in descending order like below.

How to Sort Power Apps Collection By Descending

This is how we can sort a Power Apps collection by descending order.

Power Apps Sort Collection By Ascending And Descending

Let’s discuss sorting a Power Apps collection by ascending and descending order.

Example 1:

1. I have a SharePoint Online List named “Vacation Budget.” This list contains the fields below.

Column NameData Type
DestinationIt is a default single line of a text column, I just renamed it as “Destination”
Expense TypeA single line of text
CategoryChoice
Unit PriceCurrency
Power Apps Sort Collection By Ascending Descending

2. In Power Apps, there is a Sort icon and a Data table. Whenever a user can sort the records either in ascending or descending order based on only the title column [Destination], the data table will display the sorted records.

Sort Power Apps Collection By Ascending Descending

To do so, follow the below steps.

3. On the Power Apps Canvas app -> Select the App object and set its OnStart property as:

OnStart = ClearCollect(
    colVacations,
    'Vacation Budget'
) 

Where,

  • colVacations = Power Apps Collection
  • ‘Vacation Budget’ = SharePoint Online List
How to Power Apps Collection By Ascending Descending

4. Insert a Sort icon and set its OnSelect property as:

OnSelect = Set(
    varColumn,
    "Title"
);
Set(
    varOrder,
    If(
        varOrder = SortOrder.Ascending,
        SortOrder.Descending,
        SortOrder.Ascending
    )
)

Where,

  • Set() = This Power Apps Set() function helps us to set a global variable
  • varColumn = 1st Global Variable Name
  • “Title” = SharePoint Title Field
  • varOrder = 2nd Global Variable Name
  • SortOrder.Descending, SortOrder.Ascending = Sort order can be either ascending or descending
Power Apps Sort a Collection by Ascending And Descending

5. Then, insert a Data table control and set its Items property to the code below.

Items = SortByColumns(
    colVacations,
    varColumn,
    varOrder
)

Where,

  • colVacations = Power Apps Collection
  • varColumn, varOrder = Power Apps Global Variables
Power Apps Sort the Collection by Ascending And Descending

6. Click on the Run OnStart under the App object like below.

Power Apps Sort Collection By Ascending And Descending

7. Save, Publish, and Preview the app. The Data table displays sorted records based on the selecting sort icon [Either ascending or descending] as shown below.

How to Sort Power Apps Collection by Ascending And Descending

Example 2:

  1. I will also take the same SharePoint Online list [Vacation Budget] for this example.
  2. In Power Apps, there are two button controls and a Data table.
  • Sort By A-Z: Whenever the user can sort the record based on the ascending order of the Title [Destination] column, the data table will display the records in ascending order.
  • Sort By Z-A: Whenever the user can sort the record based on the descending order of the Title [Destination] column, the data table will display the records in descending order.

Refer to the below screenshot:

Power Apps Sort a Collection By Ascending Descending

To do so, follow the below steps.

3. On the Power Apps Screen, insert two Button controls and set its OnSelect property codes as:

OnSelect = Set(
    galsort,
    "AZ"                                                      // For Ascending Order
)



OnSelect = Set(
    galsort,
    "ZA"                                                      // For Descending Order
)

Where,

  • galsort = Power Apps Global Variable
  • “AZ”, “ZA” = Variable Values
Sort a Power Apps Collection By Ascending Descending

4. Then, insert a Data table and set its Items property as:

Items = If(
    galsort = "AZ",
    Sort(
        colVacations,
        Title,
        SortOrder.Ascending
    ),
    galsort = "ZA",
    Sort(
        colVacations,
        Title,
        SortOrder.Descending
    )
)

Where,

  • If() = This Power Apps If() function evaluate the unrelated conditions
  • galsort = Power Apps Global Variable
  • colVacations = Power Apps Collection
  • Title = SharePoint Title Field
How to Sort the Power Apps Collection by Ascending And Descending

5. Run Onstart, Save, Publish, and Preview the app. The data table displays sorted records based on the selected button [Sort By A-Z and Sort By Z-A] controls as in the screenshot below.

Power Apps Sort the Collection By Ascending Descending

This is all about the Power Apps sort collection by ascending and descending.

Power Apps Sort Collection By Multiple Columns

Last, we will learn how to sort a Power Apps collection by multiple columns.

Example:

  1. I will also take the same SharePoint Online list [Vacation Budget] for this example.
  2. There is a Data table in Power Apps. This data table sorts and displays each record from the SharePoint Online list based on the two text columns, [Destination and ExpenseType].

Refer to the below screenshot:

Power Apps Sort Collection By Multiple Columns

To work around this example, follow the below steps.

3. On the Power Apps Screen -> Insert a Data table and set its Items property as:

Items = SortByColumns(
    colVacations,
    "Title",
    SortOrder.Descending,
    "ExpenseType",
    SortOrder.Ascending
)

Where,

  • “Title”, “ExpenseType” = SharePoint List Text Fields
Sort Power Apps Collection By Multiple Columns

4. Run Onstart, Save, Publish, and Preview the app. The data table displays sorted records based on the two text columns, as in the screenshot below.

How to Sort Power Apps Collection by Multiple Columns

This is how to sort a Power Apps collection by multiple columns.

Power Apps Collection GroupBy()

We can use the Power Apps GroupBy() function to return a table with records grouped based on the values in one or more columns.

Also, we can group all the records in a single record, which will act as a nested table in the Power Apps collection.

Power Apps GroupBy() Syntax

GroupBy(Table, ColumnName1[ColumnName2, ... ], GroupColumnName)

Where,

  1. Table = It is required, and it will be grouped.
  2. ColumnName (s) = We can create a group based on the column names.
  3. GroupColumnName = It stores the group records like a nested table.
  • For example, I have two Power Apps collections, i.e., colTravel [1st image] and colDestination [2nd image].
  • The first collection [ colTravel ] has the below headers:
TripTitle
Destination
TravelStartDate
TravelEndDate
Airline
EstimatedAirfare
Hotel
EstimatedHotelCost
Requestor
Approved
  • There is a second collection named “colDestination” and inside this, I will create a nested table [GroupDestination] by grouping the two columns from the previous collection, such as Airline and Destination.
Airline
Destination
GroupedDestination
Power Apps Collection GroupBy
  • Once the nested table [GroupDestination] is clicked, it will display the grouped records as shown below.
Power Apps Canvas app Collection GroupBy

To achieve the above example, follow the below-mentioned steps. Such as:

  • Open Power Apps with your credentials and create the Power Apps Canvas app where you want to group the collection records.
  • Then, select the App (from the left navigation) and choose the OnStart property to create the collections like below.
OnStart = ClearCollect(
    colTravel,
    {
        TripTitle: "Company anniversary trip",
        Destination: "Indiana,UK",
        TravelStartDate: "9/25/2023",
        TravelEndDate: "9/31/2023",
        Airline: "Alaska Air",
        EstimatedAirfare: 6000,
        Hotel: "Indiana Hotel",
        EstimatedHotelCost: 1500,
        Requestor: "Lidia Holloway",
        Approved: "Yes"
    },
    {
        TripTitle: "Research interviews",
        Destination: "Bengaluru,India",
        TravelStartDate: "10/15/2023",
        TravelEndDate: "10/20/2023",
        Airline: "SouthWest",
        EstimatedAirfare: 800,
        Hotel: "Hotel Royal Orchid Bangalore",
        EstimatedHotelCost: 1200,
        Requestor: "Lynne Robbins",
        Approved: "No"
    },
    {
        TripTitle: "Design sprint",
        Destination: "New York,UK",
        TravelStartDate: "11/22/2023",
        TravelEndDate: "11/28/2023",
        Airline: "British Airways",
        EstimatedAirfare: 5500,
        Hotel: "Hotel Mela Times Square",
        EstimatedHotelCost: 1800,
        Requestor: "Joni Sherman",
        Approved: "Yes"
    },
    {
        TripTitle: "Sales team conference",
        Destination: "Georgia,UK",
        TravelStartDate: "12/20/2023",
        TravelEndDate: "12/25/2023",
        Airline: "Emirates",
        EstimatedAirfare: 6500,
        Hotel: "Hotel grand",
        EstimatedHotelCost: 2000,
        Requestor: "Johanna Lorenz",
        Approved: "No"
    },
    {
        TripTitle: "Event and conference travel",
        Destination: "Indiana,UK",
        TravelStartDate: "12/15/2023",
        TravelEndDate: "12/18/2023",
        Airline: "Alaska Air",
        EstimatedAirfare: 6000,
        Hotel: "Indiana Hotel",
        EstimatedHotelCost: 1500,
        Requestor: "Lidia Holloway",
        Approved: "Yes"
    },
    {
        TripTitle: "Internal meetings and visiting offices",
        Destination: "Georgia,UK",
        TravelStartDate: "12/27/2023",
        TravelEndDate: "12/30/2023",
        Airline: "Emirates",
        EstimatedAirfare: 6500,
        Hotel: "Hotel grand",
        EstimatedHotelCost: 2000,
        Requestor: "Johanna Lorenz",
        Approved: "No"
    },
    {
        TripTitle: "Company retreats",
        Destination: "Bengaluru,India",
        TravelStartDate: "1/5/2024",
        TravelEndDate: "1/11/2024",
        Airline: "SouthWest",
        EstimatedAirfare: 800,
        Hotel: "Hotel Royal Orchid Bangalore",
        EstimatedHotelCost: 1200,
        Requestor: "Lynne Robbins",
        Approved: "No"
    },
    {
        TripTitle: "Client meetings",
        Destination: "Austria,UK",
        TravelStartDate: "1/20/2024",
        TravelEndDate: "1/27/2024",
        Airline: "Japan Airlines",
        EstimatedAirfare: 7500,
        Hotel: "Hotel Rand",
        EstimatedHotelCost: 1500,
        Requestor: "Johanna Lorenz",
        Approved: "No"
    },
    {
        TripTitle: "Transfers and offshore work",
        Destination: "New York,UK",
        TravelStartDate: "1/31/2024",
        TravelEndDate: "2/5/2024",
        Airline: "British Airways",
        EstimatedAirfare: 5500,
        Hotel: "Hotel Mela Times Square",
        EstimatedHotelCost: 1800,
        Requestor: "Joni Sherman",
        Approved: "Yes"
    },
    {
        TripTitle: "Bleisure travel",
        Destination: "Indiana,UK",
        TravelStartDate: "2/15/2024",
        TravelEndDate: "2/21/2024",
        Airline: "Alaska Air",
        EstimatedAirfare: 6000,
        Hotel: "Indiana Hotel",
        EstimatedHotelCost: 1500,
        Requestor: "Lidia Holloway",
        Approved: "Yes"
    },
    {
        TripTitle: "Bleisure travel",
        Destination: "Indiana,UK",
        TravelStartDate: "2/15/2024",
        TravelEndDate: "2/21/2024",
        Airline: "Alaska Air",
        EstimatedAirfare: 6000,
        Hotel: "Indiana Hotel",
        EstimatedHotelCost: 1500,
        Requestor: "Lidia Holloway",
        Approved: "Yes"
    }
)

Where,

  1. colTravel = Collection Name
  2. TripTitle, Destination, TravelStartDate = Collection Headers/Columns
  3. “Company anniversary trip”, “Indiana,UK”… = Collection Values/Records
How to use Power Apps Collection GroupBy
  • Next, click on the App more commands () option and click on the Run OnStart option to get our collection.
  • Then, go to the Variables section (x) -> Expand Collections drop-down to find collections, as shown below.
How to use a Power Apps Collection GroupBy
  • Also, if you want to see your created collection, click the View Table option and select the respective collection like below.
How to use the Power Apps Collection GroupBy
  • But here, we need to group the two columns into a single record and add a nested table to display the records in another collection (colDestination).
    • To do so, Add a Button control on the screen and set its OnSelect property to the code below:
OnSelect = ClearCollect(
    colDestination,
    GroupBy(
        colTravel,
        "Destination",
        "Airline",
        "GroupDestination"
    )
)

Where,

  1. colDestination = It is a second collection name
  2. GroupBy = This function helps us to group the multiple records in a single record
  3. colTravel = It is the first name of the Power Apps collection
  4. “Destination”, and “Airline” = These are the columns which we want to group
  5. “GroupDestination” = It is the name of the nested table
How to use GroupBy Function in Power Apps Collection
  • Now, Save, Publish, and Preview the app. Then, click on the Button control. Again, check the collections under the Variable section. There, we will get another recently created collection like the one below.
How to use a GroupBy Function in Power Apps Collection
  • Once you click on any nested table [GroupDestination], you will get the grouped data with respected columns, as shown below.
How to use GroupBy Function in a Power Apps Collection

This is all about how to use a GoupBy() function in the Power Apps collection.

Power Apps Collection Filter GroupBy()

This section will discuss filtering data on a Power Apps collection group record. Here, I will take the same example to filter the destination based on the country.

  • For example, I have a Power Apps collection, i.e., [colTravel]. In this collection, I have different records. However, as shown below, I want to filter the country based on “UK” and create another collection [DestinationByUK].
How to filter Power Apps group collection

To achieve it, follow the below steps.

  • Open the Power Apps Canvas app -> Add a Button control -> Set its OnSelect property to the code below.
OnSelect = ClearCollect(
    DestinationByUK,
    Filter(
        colTravel,
        "UK" exactin Destination
    )
)

Where,

  1. DestinationByUK = Name of the collection
  2. colTravel = It is the name of the collection that we have created
  3. “UK” exactin Destination = We can filter the destination that contains the country “UK”
Power Apps Collection Filter GroupBy
  • Then, click the Button control and check the collections under the Variable section. There, we will get another collection, i.e., DestinationByUK. Next, click on the View Table option to display results like below.
Power Apps Collection Filter using GroupBy Function

This is how we can filter group data on the Power Apps collection.

Power Apps Collection Ungroup()

Now, we will see how to ungroup the group records from a Power Apps collection.

  • For example, I have a Power Apps group collection, i.e., [colDestination]. In this collection, I have grouped the two columns, i.e., [Airline] and [Destination], in a single record [GroupDestination].
  • Now, I want to create a collection (colDestinationUngroup) that ungroups the grouped record like below.
How to ungroup the Power Apps collection grouped records

To do so, follow the below-mentioned steps. Such as:

  • Open the Power Apps Canvas app -> Select a screen where you want to add a Button control -> Set its OnSelect property to the code below.
OnSelect = ClearCollect(
    colDestinationUngroup,
    Ungroup(
        colDestination,
        "GroupDestination"
    )
)

Where,

  1. colDestinationUngroup = Name of the collection
  2. Ungroup = This function returns a table to breaking the group records in a Power Apps collection
  3. colDestination = It is the name of the collection [Source] that we want to ungroup
  4. “GroupDestination” = It is the name of the group
Power Apps Collection Ungroup
  • Next, click the Button control. Go to Variables (x) -> Expand Collections -> Select colDestinationUngroup -> Click View Table to view the result.
How to Ungroup a Power Apps Collection

This is how to ungroup the group records from a Power Apps collection using a Ungroup() function.

Power Apps Collection Group Aggregate Results

Here, we will see how to work with Power Apps Collection Group Aggregate Results.

For example, I have a Power Apps Collection, i.e. DestinationByUK. There are two number columns in this collection:

  1. EstimatedAirfare
  2. EstimatedHotelCost

Now, I would like to sum up these two columns, and the result will be displayed in a new column, i.e., Sum of the Estimated Cost.

Refer to the table below:

EstimatedAirfareEstimatedHotelCostSum of the Estimated Cost [Output]
600015007500
550018007300
650020008500
600015007500
650020008500
How to get group aggregate results in Power Apps collection

To achieve the above example, follow the below steps.

  • Open the Power Apps Canvas app -> Select a screen where you want to add a Button control -> Set its OnSelect property to the code below:
OnSelect = ClearCollect(
    colTravelSum,
    AddColumns(
        DestinationByUK,
        "Sum of the Estimated cost",
        Sum(
            EstimatedAirfare,
            EstimatedHotelCost
        )
    )
)

Where,

  1. colTravelSum = Provide a new Collection Name
  2. DestinationByUK = Collection name that we have created before
  3. “Sum of the Estimated cost” = Specify the name of the new column to display the aggregate results
  4. EstimatedAirfare, EstimatedHotelCost = These are the two columns that we want to calculate the sum
Power Apps Collection Group Aggregate Results
  • Then, click the Button control. Go to Variables (x) -> Expand Collections -> Select colTravelSum -> Click View Table to view the result.
Group Aggregate Results in Power Apps Collection

This is how we can get a Power Apps collection group aggregate results.

Also, you may like some more Power Apps tutorials:

Conclusion

I have covered Power Apps Collection OnStart here; users can get and store that data in the collection when they run or start the app using the collect function.

I have explained every step of creating a Power Apps collection manually[without data source] using the app OnStart property using the collect function and also shown you how to display that data using a Flexible height gallery control.

Moreover, we saw how to create a Power Apps Collection from Excel and how to create a Power Apps Collection using a SharePoint list. Finally, we saw how to sort a Power Apps collection alphabetically [either ascending/descending order].