web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Collection that merges...
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

Categories:
I have the same question (0)
  • Verified answer
    LaurensM Profile Picture
    12,516 Moderator on at

    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!

  • nvpc Profile Picture
    on at

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

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 337 Most Valuable Professional

#2
11manish Profile Picture

11manish 173

#3
Valantis Profile Picture

Valantis 86

Last 30 days Overall leaderboard