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 / Unnesting tables in co...
Power Apps
Answered

Unnesting tables in collection

(2) ShareShare
ReportReport
Posted on by 111
Hello all,
 
Here's my situation.  I have five different SharePoint lists that are being used to track tasks, one for each workflow.  They aren't identical in the columns of tasks, though there is some overlap.  We have 'Planting Date' being captured for each list, and Power Apps then calculates and populates task forecast dates into other columns.  Those column headers coincide with the task description.  
 
For each task, I have a forecast column and an actual column.  I have created collections for each list and then merge them into a "colUnifiedTasks" collection that I would like to use to populate a gallery, sort by Due Date, and it will serve as the to do list for tasks by telling people what is due, when, and where.
 
The current way I have this built has no errors in code, however it does nest tables in each collection by 'Field' (the location of the task to be done).  The tables look good when expanded.  
 
Essentially, the core of what I'm trying to do is to gather the Field location and Due Date (forecasted date where one exists) from each task's forecasted column where the Actual Date of the task is Blank.
 
My question is, what is the best way to unnest the tables into a flat table in the collection "colUnifiedTasks"?  Am I going about this the correct way and is there a better way?  I have used ChatGPT and Google to get to the root of how to unnest these to no avail, so I ask here.  Here are some screenshots and I'll post up how my code looks.
 
Code (used in OnSelect property of tool):
 
// SharePoint List A
ClearCollect( 
    colListA, 
    ForAll( 
        Filter('SharePoint List A', !IsBlank('Planting Date')), 
        Filter( 
            Table( 
                { Field: Field, Task: "Nursery Staked Forecast", Due: 'Nursery Staked Forecast', Actual: 'Nursery Staked Actual', SourceList: "SharePoint List A" }, 
                { Field: Field, Task: "Stand Counts Forecast", Due: 'Stand Counts Forecast', Actual: 'Stand Counts Actual', SourceList: "SharePoint List A" }, 
                { Field: Field, Task: "Conv Spray Forecast", Due: 'Conv Spray Forecast', Actual: 'Conv Spray Actual', SourceList: "SharePoint List A" }
                ), 
                !IsBlank(Due) && IsBlank(Actual) 
            ) 
        ) 
    ); 
// SharePoint List B 
ClearCollect( 
    colListB, 
    ForAll( 
        Filter('SharePoint List B', !IsBlank('Planting Date')), 
        Filter( 
            Table( 
                { Field: Field, Task: "Nursery Staked Forecast", Due: 'Nursery Staked Forecast', ActualDate: 'Nursery Staked Actual', SourceList: "SharePoint List B"},
                { Field: Field, Task: "Conventional spray forecast", Due: 'Conventional spray forecast', Actual: 'Conv Spray Actual', SourceList: "SharePoint List B"}
                ), 
                !IsBlank(Due) && IsBlank(Actual) 
            ) 
        ) 
    ); 
// SharePoint List C 
ClearCollect( 
    colListC, 
    ForAll( 
        Filter('SharePoint List C', !IsBlank('Planting Date')), 
        Filter( 
            Table( 
                { Field: Field, Task: "Task 1 Forecast", Due: 'Task 1 Forecast', ActualDate: 'Task 1 Actual', SourceList: "SharePoint List C"},
                { Field: Field, Task: "Task 2 Forecast", Due: 'Task 2 Forecast', Actual: 'Task 2 Actual', SourceList: "SharePoint List C"},                                
                { Field: Field, Task: "Task 3 Forecast", Due: 'Task 3 Forecast', Actual: 'Task 3 Actual', SourceList: "SharePoint List C"}
                ), 
                !IsBlank(Due) && IsBlank(Actual) 
            ) 
        ) 
    ); 
// SharePoint List D 
ClearCollect( 
    colListD, 
    ForAll( 
        Filter('SharePoint List D', !IsBlank('Planting Date')), 
        Filter( 
            Table( 
                { Field: Field, Task: "Task 1 Forecast", Due: 'Task 1 Forecast', ActualDate: 'Task 1 Actual', SourceList: "SharePoint List D"},
                { Field: Field, Task: "Task 2 Forecast", Due: 'Task 2 Forecast', Actual: 'Task 2 Actual', SourceList: "SharePoint List D"},                                
                { Field: Field, Task: "Task 4 Forecast", Due: 'Task 4 Forecast', Actual: 'Task 4 Actual', SourceList: "SharePoint List D"}
                ), 
                !IsBlank(Due) && IsBlank(Actual) 
            ) 
        ) 
    ); 
// SharePoint List E 
ClearCollect( 
    colListE, 
    ForAll( 
        Filter('SharePoint List E', !IsBlank('Planting Date')), 
        Filter( 
            Table( 
                { Field: Field, Task: "Task 1 Forecast", Due: 'Task 1 Forecast', ActualDate: 'Task 1 Actual', SourceList: "SharePoint List E"},
                { Field: Field, Task: "Task 2 Forecast", Due: 'Task 2 Forecast', Actual: 'Task 2 Actual', SourceList: "SharePoint List E"},                                
                { Field: Field, Task: "Task 12 Forecast", Due: 'Task 12 Forecast', Actual: 'Task 12 Actual', SourceList: "SharePoint List E"} 
            ), 
            !IsBlank(Due) && IsBlank(Actual) 
        ) 
    ) 
);
//Merge
ClearCollect(
    colUnifiedTasks,
    colListA,
    colListB,
    colListC,
    colListD,
    colListE);
 
This is the Unified Tasks collection:
 
And this is the expanded table by location, and the SourceList for this collection would coincide with say SharePoint List A in the code above.
 
Any help on how to get one singular table in a collection of the above columns that merges all Lists would be greatly appreciated.  I've been working on this for weeks now and feel so close.
 
Categories:
I have the same question (0)
  • Michael E. Gernaey Profile Picture
    53,978 Moderator on at
     
    Instead of my trying to re-write or enhance your current code, I'd prefer to go at it from the angle of this
     
    I have 5 Lists
    Across those 5 lists that have 8 columns in common
    For each list, I want to filter the rows based on ABC
    --this gives me 5 individual tables of data, that all have the same fields in them
    Now I want to merge them together into a single collection
    Also, I want to know what initial list it came from (meaning I need to "AddColumns" ) <== note I am just throwing out examples of stuff to say
     
    Now the Filter will look like this
     
    Filter(Mylist, alskdfjaksdjf = lsdjflsdkf) and each 1 is filtered the same
     
    I mean if the above you have already works, the only thing I would say is you need to use Concurrent, so that you speed it up a lot.
     
    If you want to redo it in a better way, then yeah we can chat on that. I prefer not to try to "fix" peoples code to make it better, when it may not be better to begin with, but it requries more understanding. (for me at least)
     
    Cheers
     
     
     
  • BCBuizer Profile Picture
    22,654 Super User 2026 Season 1 on at
     
    To not run into the issue with nested tables when merging the collections, you can use the below formula:
     
    //Merge
    ClearCollect(
        colUnifiedTasks,
        Ungroup(
    	Table(
        	    {myTables: colListA},
        	    {myTables: colListB},
        	    {myTables: colListC},
        	    {myTables: colListD},
        	    {myTables: colListE}
    	),
    	myTables
        )
    );
    However, I do have to agree with the previous poster: your setup seems suboptimal and may lead to issues on the long term: as your dataset will grow it will impact the performance and quality of the app. You may want to re-think the use of multiple lists and instead just use a single one.
     
     
    If this reply helped you in any way, please give it a Like 💜 and in case it resolved your issue, please mark it as the Verified Answer ✅.
  • ShanePhillips Profile Picture
    111 on at
    Hi Michael Gernaey, thanks for commenting.  Unfortunately there's quite a bit of difference between the lists, and the original intent of this app has been accomplished in keeping many hands out of the central, large excel sheet that fed a Power BI report that kept breaking from poor data quality habits.  Due to the big differences between the task requirements for each workflow, we had them separated out so that it was easier to set up from a task recording standpoint.
     
    Now this project has grown in scope.  I think it will be probably as hard to not allow tasks to be recorded for certain fields on the front end, but maybe I'm wrong.
    Also, the lists will be maybe a few hundred items long each, some much less than others.  Max is probably 300.
     
     
    BCBuizer, thank you for commenting.  I implemented that change and still have nested tables.  They're nesting by field though, so in my List B for example, I have to nested tables and then those come over in the same way to the Unified Tasks collection.  
     
    Which yields:
     
    So my individual collections are nested prior to merging and the merge ungrouping isn't pulling them out I guess.  Would I need to ungroup after each collection is made prior to merge?
     
  • BCBuizer Profile Picture
    22,654 Super User 2026 Season 1 on at
     
    Indeed in case your collections contain nested tables, those will have to be ungrouped as well, for instance when creating the collection:
     
    // SharePoint List B 
    ClearCollect( 
        colListB,
        UnGroup( 
            Filter( 
                ForAll( 
                    Filter('SharePoint List B', !IsBlank('Planting Date')), 
                    Table( 
                        { Field: Field, Task: "Nursery Staked Forecast", Due: 'Nursery Staked Forecast', ActualDate: 'Nursery Staked Actual', SourceList: "SharePoint List B"},
                        { Field: Field, Task: "Conventional spray forecast", Due: 'Conventional spray forecast', Actual: 'Conv Spray Actual', SourceList: "SharePoint List B"}
                    )
                ),
                Value 
            ), 
            !IsBlank(Due) && IsBlank(Actual) 
        )
    ); 
    Please beware this not at all delegable, so as soon as you hit more than 2000 records in your list, you'll stop retrieving new records. If you really can't change the data structure, perhaps look into using Power Automate to fetch the records instead of doing it directly from Power Apps. 
     
     
    If this reply helped you in any way, please give it a Like 💜 and in case it resolved your issue, please mark it as the Verified Answer ✅.
  • ShanePhillips Profile Picture
    111 on at
    Hi again BCBuizer, thanks for responding.  Sorry for the delay here on my side, my gf had surgery but I'm back at work.  I'll never cap at the delegation limit.  Among all five lists my max records will be about 500 total amongst all of them.  And, we've started to use the task lists as the data capture works well and at this point I don't think we can change this season.
     
    I get an error using the structure you provided below. I'm getting an error of Expected Boolean at Value, and I've tried to replace that with other things trying to resolve but have had no luck.  Also Due and Actual aren't recognized in this structure in the IsBlank filters.
     
    I have our code side by side but can't seem to wrap my head around a solution.

  • Verified answer
    BCBuizer Profile Picture
    22,654 Super User 2026 Season 1 on at
     
    I seem to have reversed the Filter and Ungroup functions in the earlier formula. Please try this pattern:
     
    // SharePoint List B 
    ClearCollect( 
        colListB,
        Filter( 
            Ungroup( 
                ForAll( 
                    Filter('SharePoint List B', !IsBlank('Planting Date')), 
                    Table( 
                        { Field: Field, Task: "Nursery Staked Forecast", Due: 'Nursery Staked Forecast', ActualDate: 'Nursery Staked Actual', SourceList: "SharePoint List B"},
                        { Field: Field, Task: "Conventional spray forecast", Due: 'Conventional spray forecast', Actual: 'Conv Spray Actual', SourceList: "SharePoint List B"}
                    )
                ),
                Value 
            ), 
            !IsBlank(Due) && IsBlank(Actual) 
        )
    ); 	
     
    If this reply helped you in any way, please give it a Like 💜 and in case it resolved your issue, please mark it as the Verified Answer ✅.
     
    Ps. Wishing for a speedy recovery
  • ShanePhillips Profile Picture
    111 on at
    Thank you so much!  I was at wits end.  I've applied it to all five lists and merged the collections.  It's flat.  :)
     
    I'd hug you if I could.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 1,055

#2
Valantis Profile Picture

Valantis 666

#2
11manish Profile Picture

11manish 666

Last 30 days Overall leaderboard