Showing results for 
Search instead for 
Did you mean: 
Frequent Visitor

Convert Patch function To UpdateIf

I have been following a Tree Hierarchy video ( to get some Collapsible/Expandable functionality but due to how the data is structured, we cannot use the Patch function. I have been led to the UpdateIf function and am struggling to figure it out. 


Here is the code that the video uses for Patch: 

        Filter(TreeItems,ThisItem.Treepath in Treepath && Treepath<>ThisItem.Treepath),
        ForAll(Filter(TreeItems,ThisItem.Treepath in Treepath&&Treepath<>ThisItem.Treepath),
        If(ThisItem.Expanded,{Shown: false },{Shown: true }))
// Patch the parent node to indicate if it is expanded/collapsed


Here is my starting point for using the UpdateIf:

UpdateIf(AllRecords_values, (Filter('[dbo].[lut_Skills]', ThisItem.Expanded=true)), {Expanded:!Expanded});


The error i am getting is either Invalid Arguments or Expecting a boolean value if i change the last part to ThisItem.Expanded:! ThisItem.Expanded. 


Any tips/pointers/etc. is appreciated. I am not tied to any one function, I am just trying to get a tree hierarchy functionality. 



I am actually using SQL database, not sharepoint. Still not working unfortunately. I do appreciate the help!

@Cscox21 ,

It is good practice to mention your data source when you post, or you may get responses that are not entirely focused on the problem. What type of field is Treepath?

Thank you for that advice. I am not entirely sure, it seems like a String data type/field but here is an snapshot of the collection: 


Because we are doing a hierarchy this (supposedly) helps with creating that tree structure. 

@Cscox21 ,

It seems to be multiple lines of text (I do not use SQL in Power Apps).

The issue is clearly this field due to the incompatible type error your are getting. You need to convert it into the field type that the query expects.


Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

Okay, i ended up getting the functionality I was looking for but it was in a totality different spot and unrelated to the Patch or UpdateIf. The Patch actually worked as intended but we were doing something with the gallery that didnt follow the video exactly. Regardless, thank you for the help!

Helpful resources

PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (1,139)