cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Yoshimitsu411
Helper II
Helper II

ClearCollect in OnStart or OnVisible

Hello

 

From a performance perspective, is it better to have my ClearCollect code running in the OnStart of my App or OnVisible of the screen or when navigating back from the Success screen?

 

I have a screen (scrEmployees) with one gallery which displays more than 2000 items from a SharePoint list. I can also update an item in this gallery. Is it better to have ClearCollect in the OnVisible of the screen such that after editing it will refresh the collection or should I call ClearCollect in the success screen before navigating back to the previous screen scrEmployees?

 

Also, is there a better way to write the code below? I'm only doing this because the delegation limit is set to 500. I don't want to increase it to 2000.

 

Concurrent(
    ClearCollect(
        EmpNew, Filter(Employees, 'Employee Status'.Value="New")
    ),
    ClearCollect(
        EmpInProgress, Filter(Employees, 'Employee Status'.Value="In Progress")
    ),
    ClearCollect(
        EmpCompleted, Filter(Employees, 'Employee Status'.Value="Completed")
    ),
    ClearCollect(
        EmpPending, Filter(Employees, 'Employee Status'.Value="Pending")
    ),
    ClearCollect(
        EmpClosed, Filter(Employees, 'Employee Status'.Value="Closed")
    )
);
ClearCollect(
    EmployeesCollection,
    EmpNew,
    EmpInProgress,
    EmpCompleted,
    EmpInvoicePending,
    EmpClosed
)

 

I'm keen to know how best to manage this ClearCollect call without slowing down performance as I have approximately half a dozen people using the app at any given time and several screens like the one above in the future.

 

Thanks

Yoshi

4 REPLIES 4
WarrenBelz
Super User
Super User

Hi @Yoshimitsu411 ,

OnStart is fine and the number of people (in that small number) will have no effect. You are also using Concurrent and all the filters are Delegable, however a Collection in itself is subject to the Delegation limit, so each collection is limited to 500 records (and the end one a maximum of 2,500 as a result).

 

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.

Visit my blog Practical Power Apps

 

 

Thanks @WarrenBelz , that also answers another issue I was having with why my collection wasn't showing all the status values in my filter gallery. 

 

I am only seeing In Progress, Completed and Invoice Pending and that's probably because there are more than 2000 items and is being restricted due to delegationas you mentioned. I didn't realise Collections had restrictions which is why I used Concurrent to work around it. I might have to read up on this a bit more.

 

Any suggestions how how I can see all my Status values and a count in my filter gallery?

 

For example

 

New (14) >

In Progress (433) >

Completed (569) >

Invoice Pending (840) >

Closed (750) >

 

In reality, I'm only seeing.

 

In Progress (433) >

Completed (569) >

Invoice Pending (840) >

 

Thanks

Yoshi

Hi @Yoshimitsu411 ,

I would have thought that you would get the total of all five collections in the last one - try this to see if it makes a difference (you should not however have to do this)

ClearCollect(
    EmployeesCollection,
    EmpNew
);
Collect(
   EmployeesCollection,
   EmpInProgress
);
Collect(
   EmployeesCollection,
    EmpCompleted
);
Collect(
   EmployeesCollection,
    EmpInvoicePending
);
Collect(
   EmployeesCollection,
   EmpClosed
)

 

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.

Visit my blog Practical Power Apps

 

 

Thanks @WarrenBelz , I worked it out.

 

In my filter gallery > Items = Sort(Distinct(EmployeesCollection, 'Employee Status'.Value),Result,Ascending)

 

I then added a label to display the total number for each distinct status in the gallery using my list data source and not the collection > Text = CountRows(Filter([@'Employees'], 'Employee Status'.Value=ThisItem.Result))

Helpful resources

Announcements
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 (4,856)