cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Cscox21
Frequent Visitor

Convert Patch function To UpdateIf

I have been following a Tree Hierarchy video (https://www.youtube.com/watch?v=qJv8IqqL01A&t=575s) 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: 

Patch(
    TreeItems,
        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
Patch(
    TreeItems,
        Filter(TreeItems,ThisItem.Treepath=Treepath),
        ForAll(Filter(TreeItems,ThisItem.Treepath=Treepath),
        {Expanded:!Expanded})
)

 

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. 

Thanks

14 REPLIES 14

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: 

Cscox21_0-1620655920351.png

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

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

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.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (1,103)