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.

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

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

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