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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Patch all possible com...
Power Apps
Unanswered

Patch all possible combinations to separate rows from two different List Boxes

(0) ShareShare
ReportReport
Posted on by 29

Hello, I am creating a sign up app and based on what the user selects, I need the app to output to an sharepoint table called "Responses" so that an upstream process can use it. I am very new to PowerApps and am struggling to accomplish this without the ability to code or create a for loop. I have attempted to use multiple ForAll functions, but this does not appear to be working as I intended. 

 

In my app, the user can sign up for multiple reports for multiple different operations, so I have two list boxes for each of these steps. During the "Report" step, the user could sign up to receive report A & B for example, and in the "Operation" step could sign up for operations C & D. Upon final submission on the confirmation page of the app, I want to update the "Respones" table with all possible records from the selected items in the list boxes, along with the users email for all records. 

 

Desired output is below from example:

EmailReportSelectedOperationSelected
user@email.comAC
user@email.comBC
user@email.comAD
user@email.comBD

 

However, my function is not working, although it compiles it simply writes the last selected option in Operation for all records instead. It does correctly cycle for one column, but the other column does not change as intended. In the code below SelectedReport is a table with length 2 compiled from the Report list box, same is true with SelectedOperation. 

 

Current code below on the final submit button is as follows:

If(BreakdownRadio.SelectedText.OptionText = "Operation",
Set(varRecord,
ForAll(SelectedOperation,
ForAll(SelectedReport,
Patch(Responses,Defaults(Responses),
{ResponseId:CountRows(Responses)+1,
EmailAnswer:EmailInput.Text,
ReportSelected:Value,
OperationSelected: OperationList.SelectedText.Value}))))

 

Current Output created, which is wrong. 

EmailReportSelectedOperationSelected
user@email.comAD
user@email.comBD
user@email.comAD
user@email.comBD

 

I was chatting with this @Geeks_D on another thread, and he suggested the following, but thought I would create a new thread. 

 

"use collection and a ForAll with AddColumns 

When Items are selected in OperationsList a collection is created for all selected Items 
After the selection a new collection is created with a ForAll function to add the required values from the other list " 

 

The logic of it makes sense but I'm struggling to functionalize the logic in PowerFX and am looking for some additional guidance on how to accomplish this. 

 

For anyone who is working with only a single list box, please reference this solved thread which has an excellent solution from @Geeks_D.

Categories:
I have the same question (0)
  • relges0616 Profile Picture
    29 on at

    @GeeksD I compiled the two list boxes into a single collection, but it only creates a single column equal to the length of one list box plus another list box. In my example this is not an issue since (2+ 2 = 2 x 2), but how would I create a collection with an additional column to ensure I get the proper number of records? For example, if each list box had 4, the code below only creates 8 records in that scenario, but it should create 16. 

     

    ClearCollect(CollectionMain,SelectedOperation, SelectedReport);

     

    Thanks for your help.

     

  • relges0616 Profile Picture
    29 on at

    I've also tried this code. It compiles but doesn't seem to work. It creates a collection with a single column and for each record there is a table, instead of creating two columns. 

     

    Any help would be very appreciated, the app is beginning to gain steam and I need this functionality to properly serve the upstream process. 

     

    ClearCollect(
           ResponseCollection,
           ForAll(
                SelectedReport,
                ForAll(
                  SelectedOperation,
                  {
                        ReportColumn: SelectedReport.Value,
                         OperationColumn: SelectedOperation.Value
                  }
             )   
          )
    );

     

     

    relges0616_0-1704401490037.png

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 711 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 319 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard