I have the following Sp Lists:
StudentClasses |
TeachersGrades |
I need to create a collections to use in a gallery. This collections will display the Teachers grades horizontally.
Thanks in advance
Thank you, this works! I was over thinking and was trying to create a "pivot table".
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!
WarrenBelz
146,552
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,928
Most Valuable Professional