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 / Transposing and Mergin...
Power Apps
Answered

Transposing and Merging Collections

(0) ShareShare
ReportReport
Posted on by 19

I am working on a solution for one of our clients where I need to merge a collection with transpose of a row in another collection as explained below:

 

PowerSoumyo_0-1624347021516.png

 

The two tables on the left represent the two collections that I already have, storing the question data and another one storing the responses to those questions by each user. When admin users log in to the app, they see a gallery of responses (just a title, not the detailed responses) and when they click on a title, the detailed responses from collection 2 will need to be displayed in the format shown in the output collection above. Let me know if this will be feasible or will the solution needs to be designed differently. Thanks in advance.

 

Categories:
  • Verified answer
    Al_10 Profile Picture
    1,691 Super User 2024 Season 1 on at

    @PowerSoumyo 

    If Collection2 is a data source for admin gallery (lets call adminGallery):

     

    adminGallery.OnSelect = 

    Clear(colCollection1_2);
    ForAll(colCollection1 As ThisQues,
        Collect(colCollection1_2,
        {
        'QuesID': ThisQues.QuesID,
        'Ques': ThisQues.Ques,
        'Response': Switch(ThisQues.QuesID,
        "Q1", ThisItem.Q1,
        "Q2", ThisItem.Q2,
        "Q3", ThisItem.Q3,
        "Q4", ThisItem.Q4,
        "Q5", ThisItem.Q5
        )})
    )

     

     

    create a new gallery (lets call resultGallery):

    resultGallery.Items = colCollection1_2

     

     

  • PowerSoumyo Profile Picture
    19 on at

    Thanks for your help @Alex_10 

    So, this means whenever a new question is added to the data source, my app will need to be updated in the Switch part of the formula, correct? Is there a way to make that automatic?

  • Al_10 Profile Picture
    1,691 Super User 2024 Season 1 on at

    @PowerSoumyo 

    yes, you are right.

    to make it in auto mode, you need to redesign COllection2 - each question answer has to be a separate column like:

     

    PersonID              QuesID     Answer

    ---------------------------------------

    John_Doe_ID          Q1            yes

    John_Doe_ID          Q2            no

    Jane_Doe_ID          Q1             no

  • PowerSoumyo Profile Picture
    19 on at

    @Alex_10 Thanks again So, which one of these designs (top or the bottom one) do you think will be better:

     

    PowerSoumyo_0-1624462592009.png

     

    And if I go with the second design that you suggested (bottom), will the following formula work to merge the two collections and get the desired output as per my requirement:

     

    ClearCollect(newCol, Addcolumns(Col2,"ques",lookup(col1,QuesID=col2[@Question]).Ques))

  • Al_10 Profile Picture
    1,691 Super User 2024 Season 1 on at

    @PowerSoumyo 

    with the bottom collection that code should work in general.

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 360 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 325

#3
Mohsin Ali Profile Picture

Mohsin Ali 232

Last 30 days Overall leaderboard