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 / Strange behaviour with...
Power Apps
Answered

Strange behaviour with Patch, AddColumns and nested tables

(0) ShareShare
ReportReport
Posted on by 91

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

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

    @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.

     

  • MichaB12 Profile Picture
    91 on at

    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!

     

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

    @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".

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 342 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 271

#3
Mohsin Ali Profile Picture

Mohsin Ali 223

Last 30 days Overall leaderboard