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

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (4,175)