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 / How to CleaCollect fro...
Power Apps
Answered

How to CleaCollect from a nested gallery?? Need Help! :)

(0) ShareShare
ReportReport
Posted on by 61

Hello

I have 2 galleries "Gal1" and "Gal2"

 

"Gal1" has a "GroupBy" as an Item - eks. "GroupBy(Table,Column,DATA)"

"Gal2" has "ThisItem.DATA" an a Item

 

When i use ClearCollect on Gal2 i only get rows from items that is selected in gal1, however i want all the rows from the table

 

PS: Its important to get the rows from Gal2, because i have a toggle in that gallery that i need.

 

Anyone can help?

Categories:
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @JohnMarkPerez 

    What are you trying to collect (duplicate) from your Gallery?  The gallery already has all the data in it, there is no need to duplicate it.

     

    If you reference the gallery instead, you can access the sub galleries in it and their items as well.

     

    But, it is not clear what you are ultimately trying to gather/obtain from your gallery.  If you could expand on that, it would be helpful.

     

     

  • JohnMarkPerez Profile Picture
    61 on at

    Hello @RandyHayes 

    Take a look at the image below, the "Yellow" is Gal1 and the "Green" is Gal2. The last selected gal2 is what i get from clearcollect. If i had selected the "gal2" that contains the 3 rows i get 3 rows. However when i select the one with 1 row i get 1 row. I want to get all 4 rows.

     

    Udklip.PNG

     

  • JohnMarkPerez Profile Picture
    61 on at

    i use = ClearCollect(colName,Gal2.AllItems)

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @JohnMarkPerez 

    Yes...you are referencing the Gal2 out of context of the master gallery.

     

    THERE IS A TRICK!!  A Nested Gallery is part of a master gallery and it is referenced in the AllItems of the master gallery.  BUT, the nested gallery will not "give up" its values unless the master gallery references it directly.

     

    So, to do this, you can simply add a label (not to be visible...just to force the nested gallery to give up its goods) to the master gallery that has a Text property of: CountRows(Gal2.AllItems)

    This will force the Gal1 to be "aware" of Gal2 items.  The above formula is not relevant to it...you can do any formula that references the items in the Gal2, but the above is an easy one.

     

    Your Formula for all of your toggled items would then be:

    Ungroup(
     ForAll(Gal1.AllItems, Filter(Gal2.AllItems, ToggleControlName.Value)),
     "Value"
    )

     

    This can be used to populate a collection...but my original point - the Gallery already has these values, there is no relevant need to duplicate them into yet another part of your app memory... you can just use the above to get to what you need.

  • JohnMarkPerez Profile Picture
    61 on at

    @RandyHayes 

    I dont understand this solution, i need the data in a collection because i need to use "Patch" to save these data outside of Power Apps.

  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @JohnMarkPerez 

    That formula I provided will give you a table!  If you want to put that table into another table (a collection) you can certainly duplicate it.

     

    But, if you just want to patch a datasource, then you already have what you need.

    This formula would, for example, patch your datasource:

    Patch(yourDataSource,
     ForAll(
     Ungroup(
     ForAll(Gal1.AllItems, Filter(Gal2.AllItems, ToggleControlName.Value)),
     "Value"
     ),
     {ID: ID,
     ColumnYouWantToChange: ValueForColumn
     }
     )
    )
  • JohnMarkPerez Profile Picture
    61 on at

    @RandyHayes 

    I think we are so close its not giving me all the rows instead its giving me the number og rows og my Gal1.

     

    Do you have 5-10 for a Teams-VideoCall, To help me - Il treat to a cup of cooffe 🙂

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @JohnMarkPerez 

    Can you post your current formula?  Let me take a look at that first.  If I can't determine the issue from that, then I will see what I can schedule for a call.

  • JohnMarkPerez Profile Picture
    61 on at

    @RandyHayes 

    I think i understand your syntax better now. I get all the rows with a "true" value - However i would like to also get the rows with "false" value. I will make you 2nd answer as a sulotion. But i would like it if you kan show me how to get the rows with false value also.

    Udklip 1.PNG

    Udklip 2.PNG

  • JohnMarkPerez Profile Picture
    61 on at

    This is the result:

    Udklip 3.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

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 July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 409 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 252 Most Valuable Professional

Last 30 days Overall leaderboard