How to Create Power Apps Collection from Multiple SharePoint Lists?

In this Microsoft Power Apps tutorial, I will explain how to create Power Apps Collection from Multiple SharePoint Lists. Then, I will show you how to add a data source to the Power Apps collection.

Moreover, we will discuss how to manage two SharePoint data lists in the Power Apps collection. Last, we will cover how to display the Power Apps collection on a data table from two SharePoint lists.

Create Power Apps Collection from Multiple SharePoint Lists

We can create a Power Apps collection using multiple SharePoint Online lists and easily display the Power Apps collection on a data table control.

  • Let’s take a simple scenario: I have two SharePoint Online Lists, i.e.,
  1. Training Courses
  2. Tutor of Training Courses
  • The first SharePoint list (Training Courses) has the following columns with different data types.
Column NameData Type
Course NameIt is a default single line of text and I renamed as “Course Name”
DescriptionIt is a “Multiple lines of text”
Choose TechnologyIt is a “Choice” column
Start DateIt is a “Date and time” column
End DateIt is a “Date and time” column
  • The second SharePoint list (Tutor of Training Courses) has the following columns with different data types.
Column NameData Type
Course NameIt is a default single line of text and I renamed as “Course Name”
TutorIt is a “Person or Group” column
How to Create Power Apps Collection from Multiple SharePoint Lists

I want to create a Power Apps collection, i.e., [colCourses]. I have added data from the two SharePoint Online lists in this collection.

  • For example, I want to display the collection on a data table using the first SharePoint list [Training Courses] columns and add one more column, i.e., [Tutor] from the second SharePoint list [Tutor of Training Courses] as shown below.
Create Power Apps Collection from Multiple SharePoint Lists

To work around the above scenario, follow the below two examples. Such as:

Example 1: Create Power Apps Collection from Multiple SharePoint Lists [Using Patch() Function]

Here, we will discuss how to create a Power Apps collection from multiple SharePoint lists using the Patch() function. To achieve it, follow the below steps.

  • Open your Power Apps with your credentials -> Create a Canvas app where you want to add a collection -> Add data from SharePoint lists like the one below.
Create a Power Apps Collection from Multiple SharePoint Lists
  • Then, rename the default screen (MultipleCollectionScreen) -> Insert a Button control (Collection from multiple SharePoint lists) -> Set its OnSelect property as:
OnSelect = Collect(
    colCourses,
    ForAll(
        'Training Courses' As _item,
        Patch(
            _item,
            {
                Tutor_Found: LookUp(
                    'Tutor of Training Courses',
                    Title = _item.Title,
                    Tutor
                )
            }
        )
    )
)

Where,

  1. colCourses = Collection name
  2. ‘Training Courses’ = Name of the 1st SharePoint list
  3. Tutor_Found = It is a column that we want to add to the collection
  4. Patch = This Patch () function to modify records in complex situation
  5. ‘Tutor of Training Courses’ = Name of the 2nd SharePoint list
How to create a Power Apps collection from multiple SharePoint lists
  • Now, insert a Data table and set its Items property as:
Items = colCourses
How to create a Power Apps collection using multiple SharePoint lists
  • To display the collection fields in the data table control, click the Edit fields option and add fields as needed.
How to create Power Apps collection from multiple SharePoint lists
  • Now, click on the button control [Collection from multiple SharePoint lists] to display all columns along with the “Tutor” column on a data table.
Power Apps Create Collection using Multiple SharePoint Lists

This is how to create a Power Apps collection from SharePoint lists using the Patch() function.

Example 2: Create Power Apps Collection from Multiple SharePoint Lists [Using LookUp Function]

Let us discuss how to create a collection using the lookup function. To do so, follow the below steps.

  • On the Power Apps Screen -> Insert a Button control [Create Collection with Two SP Lists] -> Set its OnSelect property code like below.
OnSelect = With(
    {
        CourseTutor: RenameColumns(
            'Tutor of Training Courses',
            "Title",
            "CourseName"
        )
    },
    ClearCollect(
        colCourseTutor,
        AddColumns(
            'Training Courses',
            "Tutor",
            LookUp(
                CourseTutor,
                CourseName = Title
            ).Tutor
        )
    )
)

Where,

  1. CourseTutor = It is the scope of the formula to define the collection
  2. ‘Tutor of Training Courses’ = Second SharePoint Online List
  3. “Title”, “CourseName” = these are the rename columns
  4. colCourseTutor = Collection name
  5. ‘Training Courses’ = First SharePoint Online List
  6. “Tutor” = Lookup column
  7. LookUp = By using this function to evaluate the records of the table based on a single condition
Create a Power Apps collection using multiple SharePoint lists
  • Then, insert a Data table and set its Items Property as:
Items = colCourseTutor
  • To display the collection fields in the data table control, click the Edit fields option and add fields as needed.
Create Power Apps Collection using Multiple SharePoint Lists
  • Now, click on the button to display the Power Apps collection with all the columns as shown below.
How to Create a Power Apps Collection from Multiple SharePoint Lists

This is how to create a Power Apps collection from multiple SharePoint lists using the LookUp() function.

Also, you may like some more Power Apps tutorials:

Conclusion

Whenever you want to create a Power Apps collection using multiple SharePoint Online lists, you can add SharePoint lists as values in the Power Apps collection.

From this Power Apps tutorial, I have explained all about creating a Power Apps collection from multiple SharePoint Online lists.

Also, we covered how to add data sources [SharePoint Lists] to the Power Apps collection and how to manage the two SharePoint lists in the Power Apps collection. And finally, we saw how to display the collection on a data table control.