Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Collection that merges two SP list and display data horizontally to use in a gallery

(0) ShareShare
ReportReport
Posted on by

I have the following Sp Lists:

StudentClasses

 

TeachersGrades

nvpc_0-1697988847950.pngnvpc_1-1697989149906.png

 

nvpc_2-1697989261544.png

I need to create a collections to use in a gallery. This collections will display the Teachers grades horizontally.

Thanks in advance

  • nvpc Profile Picture
    on at
    Re: Collection that merges two SP list and display data horizontally to use in a gallery

    Thank you, this works! I was over thinking and was trying to create a "pivot table".

  • Verified answer
    LaurensM Profile Picture
    12,510 Super User 2025 Season 1 on at
    Re: Collection that merges two SP list and display data horizontally to use in a gallery

    Hi @nvpc,

     

    There is no built-in function to transpose rows into columns dynamically. However, as long as you know the amount of columns that need to be added - we can add them manually. 😊 To keep the code short, I have created an example for the first 2 teachers.

     

    ClearCollect(
     colMergedClassGrades,
     //Add columns to StudentClasses
     AddColumns(
     StudentClasses,
     "Teacher - 1",
     //Fetch the grade linked to the current ClassID & Teacher 1
     LookUp(
     TeachersGrades As Inner,
     ClassID = Inner.ClassID && Inner.TeacherID = 1,
     Inner.Grade
     ),
     "Teacher - 2",
     //Fetch the grade linked to the current ClassID & Teacher 2
     LookUp(
     TeachersGrades As Inner,
     ClassID = Inner.ClassID && Inner.TeacherID = 2,
     Inner.Grade
     )
     )
    )

    Using ClearCollect is not necessary, you can use the AddColumns code directly in the Items property of the gallery.

     

    If this solves your question, would you be so kind as to accept it as a solution & give it a thumbs up.

    Thanks!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,552 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,928 Most Valuable Professional

Leaderboard