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 Collapse Rows
Power Apps
Answered

Collection Collapse Rows

(0) ShareShare
ReportReport
Posted on by 30

Another new to PowerApps user post..

 

I have two SharePoint lists: Questions and Answers.  The Questions list builds a gallery, displaying the question and answer controls (controls are hidden/visible based upon the field type in the Questions list).

 

The issue I'm having, is trying to flatten the gallery so that we only patch one row instead of one row for each gallery item.

 

QUESTION LIST

IDQUESTIONQUESTIONTYPEQUESTIONLIST
1Question #1TextBox 
2Question #2DropdownQUESTION2_LIST
3Question #3RadioYN 

 

ANSWER LIST - Current

IDNAMEQ1Q2Q3
1XYZAnswer 1  
2XYX DropDownItem1 
3XYZ  Yes

 

ANSWER LIST - flattened

IDNAMEQ1Q2Q3
1XYZAnswer 1DropDownItem1Yes

 

 

ForAll(
 galQuestions.AllItems,
 Collect(
 newlist,
 {
 Name: ClientName.Text,
	 Q1: If(
 Value(ThisRecord.lblQuestionNumber.Text) = 1 && ThisRecord.QuestionType.Value = "DropDownList" && !IsBlank(ThisRecord.ddlAnswer.SelectedText.Value),
 ThisRecord.ddlAnswer.SelectedText.Value,
 Value(ThisRecord.lblQuestionNumber.Text) = 1 && ThisRecord.QuestionType.Value = "TextBox" && !IsBlank(ThisRecord.txtAnswer.Text),
 ThisRecord.txtAnswer.Text,
 Value(ThisRecord.lblQuestionNumber.Text) = 1 && ThisRecord.QuestionType.Value = "RadioButtonYN" && !IsBlank(ThisRecord.rbAnswer.Selected.Value),
 ThisRecord.rbAnswer.Selected.Value
 ),
 Q2: If(
 Value(ThisRecord.lblQuestionNumber.Text) = 2 && ThisRecord.QuestionType.Value = "DropDownList" && !IsBlank(ThisRecord.ddlAnswer.SelectedText.Value),
 ThisRecord.ddlAnswer.SelectedText.Value,
 Value(ThisRecord.lblQuestionNumber.Text) = 2 && ThisRecord.QuestionType.Value = "TextBox" && !IsBlank(ThisRecord.txtAnswer.Text),
 ThisRecord.txtAnswer.Text,
 Value(ThisRecord.lblQuestionNumber.Text) = 2 && ThisRecord.QuestionType.Value = "RadioButtonYN" && !IsBlank(ThisRecord.rbAnswer.Selected.Value),
 ThisRecord.rbAnswer.Selected.Value
 ),
 Q3: If(
 Value(ThisRecord.lblQuestionNumber.Text) = 3 && ThisRecord.QuestionType.Value = "DropDownList" && !IsBlank(ThisRecord.ddlAnswer.SelectedText.Value),
 ThisRecord.ddlAnswer.SelectedText.Value,
 Value(ThisRecord.lblQuestionNumber.Text) = 3 && ThisRecord.QuestionType.Value = "TextBox" && !IsBlank(ThisRecord.txtAnswer.Text),
 ThisRecord.txtAnswer.Text,
 Value(ThisRecord.lblQuestionNumber.Text) = 3 && ThisRecord.QuestionType.Value = "RadioButtonYN" && !IsBlank(ThisRecord.rbAnswer.Selected.Value),
 ThisRecord.rbAnswer.Selected.Value
 ) 
 }
 )
);

 

 

Any help/direction would be appreciated.

 

Shout out to Shane Young & Pragmatic Works for some great videos. They've been a tremendous help in getting up to speed with PowerApps & Power Automate.

 

Categories:
  • Verified answer
    Adrian_Celis Profile Picture
    1,652 Moderator on at

    Hi @pjdiii 

    If you want the flattened list like you showed, you can ignore the ForAll and the use lookup to get the question per number. The code below is simplified just to show you, I did not add the If conditions but this is the general idea.

    Collect(
     newlist,
     {
     Name: ClientName.Text,
    	 Q1: LookUp(galQuestions.AllItems, Value(lblQuestionNumber.Text) = 1).ddlAnswer.SelectedText.Value,
     Q2: LookUp(galQuestions.AllItems, Value(lblQuestionNumber.Text) = 2).ddlAnswer.SelectedText.Value,
     Q3: LookUp(galQuestions.AllItems, Value(lblQuestionNumber.Text) = 3).ddlAnswer.SelectedText.Value,
     }
     );
    

     

  • pjdiii Profile Picture
    30 on at

    Thanks @Adrian_Celis works perfectly!

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 236 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 207 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 169

Last 30 days Overall leaderboard