Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Strange behaviour with Patch, AddColumns and nested tables

(0) ShareShare
ReportReport
Posted on by 89

Hi,

 

I have 2 collections, c1 just contains values, and c2 is the result of a groupBy of b column of c1:

ClearCollect(c1, {a:1, b:1}, {a:2, b:1}, {a:3, b:3}, {a:4, b:1});
ClearCollect(c2, GroupBy(c1,"b", "rest"))

 

So in the c2 collection we have 2 columns:

  • "b" which contains a value
  • "rest" which contains a single column table named "a"

 

Let's say I want to update the first row of c2, I want to add a new column to the table in the "rest" column.

 

I tried to construct this new table elsewhere like this and it worked well:

AddColumns(First(c2).rest, "test", true)

 

But when I want to apply the changes to c2 with Patch it doesn't work:

Patch(c2, First(c2), {b:-1, rest:AddColumns(First(c2).rest, "test", true)})

 

Event stranger, I can change the "b" column value without any problem. So there is probably something I am missing with tables. Could anyone explain me what I don't understand here? Why is the table not changed in c2 collection?

 

Thanks

  • RandyHayes Profile Picture
    76,287 Super User 2024 Season 1 on at
    Re: Strange behaviour with Patch, AddColumns and nested tables

    @MichaB12 

    Yes, that is exactly what to do.  You need to define the schema from the very start.  Note that this is relevant to "modifying" an existing table.  You can derive new tables from existing with modified column - this is what shaping data is all about.  But, once you define the schema, it is what is referenced and used - and "set".

  • MichaB12 Profile Picture
    89 on at
    Re: Strange behaviour with Patch, AddColumns and nested tables

    Oh I didn't know that... Thanks! 

     

    Well with that in mind I managed to add this column at the creation of the main table. I used a groupBy to create this nested table, so I just added the AddColumns before the GroupBy and now I don't need to add this column later 🙂 

     

    Thank you for your reply!

     

  • Verified answer
    RandyHayes Profile Picture
    76,287 Super User 2024 Season 1 on at
    Re: Strange behaviour with Patch, AddColumns and nested tables

    @MichaB12 

    You cannot change the schema like that in a table column of a collection table.  Schema is highly important in PowerApps.

     

    What is it that you are trying to achieve?  This is very "programmatic" from what it appears - Keep in mind, PowerApps is modeled after Excel - it is not a development platform.

     

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 1