cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Joorge_c
Resolver I
Resolver I

Cannot Collect on SubGallery(Nested)

Hi All, Im having an issue, I cannot collect Items in a nested gallery.

Im keeping a CountRows label to double check if anything was collected and it comes back with zero all the time.

 

Trying simple code, creates all the fields with an empty Collection.

ClearCollect(BLTUpdates,GallerySubCat.AllItems)

Trying the defined approach(wanted code), does the same, 0 rows saved.

Clear(BLTUpdates);
ForAll(
    GallerySubCat.AllItems,
    Collect(
        BLTUpdates,
        {
            Type: Type,
            Month: PSA_Month_Summary.Text,
            Area: Dropdown_Area_2.Selected.Result,
            LM: Dropdown_LM_2.Selected.Result,
            ContractType: SubCat,
            Owner: CurrUserName,
            ICP: ICP_Name,
            Branch: "Branch",
            '$': Value(TextInput1.Text),
            Margin: Value(TextInput1.Text) * Margin
        }
    )
)

 

My Parent Gallery Items code

Distinct(Filter(CatOrder,Type="Secured Volume"),MainCat)

My Nested Gallery Items code.

Filter(CatOrder,MainCat= ThisItem.Result)

Could I try any other ideas?

Thank you!

9 REPLIES 9
WillPage
Impactful Individual
Impactful Individual

Try using the GroupBy function to create a table of distinct MainCats and then add a column to it which counts the rows of the child item, then sum that.

 

AddColumns(GroupBy(Filter(CatOrder,Type="Secured Volume"),"MainCat"),"ChildCount",CountRows(ThisRecord.MainCat))

 

 Now to get the total count:

 

Sum(AddColumns(GroupBy(Filter(CatOrder,Type="Secured Volume"),"MainCat"),"ChildCount",CountRows(ThisRecord.MainCat)),ChildCount)

 

Thanks @WillPage 

Im really trying to capture all these fields in the sub category, not interested in counting the rows, just wanted to double check with a count.

It appears when I use the goupby, I lose all the other columns I neead to save.

Joorge_c
Resolver I
Resolver I

@WillPage So I created a separate Test Gallery, with only 1 field in MainGallery 1 in SunGallery. Still cannot get this to collect as it should.

 

Main Category Gallery1

GroupBy(Filter(CatOrder,Type="Secured Volume"),"MainCat","MainCatGr")

 

SubCat Gallery2

Sort(Distinct(ThisItem.MainCatGr.SubCat,SubCat),Result)

 

Button OnSelect

ClearCollect(BLTUpdatesTest,Gallery2.AllItems)

WillPage
Impactful Individual
Impactful Individual

@Joorge_cWhen you use GroupBy(), the column you group by becomes an object that contains all the other columns. So, for example if you have nested galleries you would do this:

Outer Gallery Items:

GroupBy(Source, "GroupColumn")

Inner Gallery Items:

ThisItem.GroupBy

Your inner gallery now has access to all the other columns that are unique (or not grouped) for each record, e.g ThisItem.Title, ThisItem.ID etc.

Drrickryp
Super User
Super User

@Joorge_c 

Please see this screenshot1.jpg
This shows a gallery with the table within a table (Departments and Names) on the left.  The big button on the top ungroups the Department collection on Name. and the datatable below it shows the ungrouped departments.  As you can see in the screenshot below, The DepartmentCollection contains the departments and the Name is another table.  It is very likely that you have the same thing that is causing your issue. 
2.jpg

 

My guess is that you are in this predicament because you have used either Choice or Lookup type fields in your SharePoint list. These complex type fields create a table within a table and IMHO should not be used.    Please see my post here. https://powerusers.microsoft.com/t5/News-Announcements/The-Ten-Commandments-of-SharePoint-in-PowerAp...  and note #1.  

Everything the more complex column types do can be easily replicated in PowerApps using single line of text, numbers, and Date/Time column types in SharePoint.

 

 

Thanks @WillPage  I realized this in my second attempt. unfortunately it still didnt collect the nested gallery... sorry I tried to respond and clicked resolved by mistake lol.

hey @Drrickryp  thanks for the reply.

I initially thought if the issue could be the source of the Galleries, the weird thing, is it is an Excel Static imported table, where Column1 has the Main Category and Column2 with more detailed breakdown is Column2.

 

I have thought of separating the 2 Columns into different Table Sources (same excel static tables) and to try to replicate the main/nested gallery, but I do not think this should be the issue.

Any other ideas?

@Drrickryp  so I have now been trying to replicate the Nested Gallery collection from other means of data, even created collections of tables to try to collect from the nested Gallery based on Collection sources and I cannot get the nested gallery collect to work.

 

It even feels like I have some sort of setting turned off. I have checked all other posts, code being used seems to be Ok, have also tried alternative ways with other correct codes, but it is just not working for me.

Any other thoughts?

Joorge_c
Resolver I
Resolver I

Anyone else that could give this a try? I feel like there could be a problem with PowerApps. Ive created a fresh App and used alternate data to try otherways without being able to collect on a sub category.

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (2,124)