cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
seadude
Memorable Member
Memorable Member

DELEGATION: Workaround?

Anyone got a quick tip for getting around the delegation warning thrown here?

CountRows(
    Filter(
        '[dbo].[myTable]',
        createdDate <= ThisItem.date
    )
)

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @seadude,

I always rise to a challenge.  One way to do it is to somehow get all of the results into a collection.  The problem here is that Collect and ClearCollect are also not delegated so you would have to split your Filter function so that it only collected <2k records at a time.  As an example, suppose you are collecting data over several years and that each year you never collect over 2k records.  

Concurrent( ClearCollect(yr2016, Filter('[dbo].[myTable]', Year(createdDate) = Year(Now()-2),
ClearCollect(yr2017, Filter( '[dbo].[myTable]',Year(createdDate) = Year(Now())-1),
ClearCollect(yr2018, Filter( '[dbo].[myTable]', Year(createdDate) = Year(Now())); Collect(allyears,yr2016);Collect(allyears,year2017);Collect(allyears,year2018)

CountRows(allyears) should give an accurate count all of your records. You could also CountRows on each subcollection ie CountRows(yr2017) and be sure that none of the rows is >2000.  Then sum the CountRows label values. 

View solution in original post

9 REPLIES 9
v-monli-msft
Community Support
Community Support

Hi @seadude,

 

Accourding to documentation:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/delegation-overview

Counting functions such as CountRowsCountA, and Count can't be delegated.

 

I have found an idea submitted asks for this feature, the status of this idea is planned. Please vote here:

https://powerusers.microsoft.com/t5/PowerApps-Ideas/Extend-delegation-to-Sum-and-CountRows/idi-p/231...

 

Regards,

Mona

Community Support Team _ Mona Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks for the response @v-monli-msft, I'll vote on the idea.

What about @Drrickryp? You have suggested some great delegation work arounds in the past. Do you know a way to get a count of a filtered range without hitting the limits?

Hi @seadude,

I always rise to a challenge.  One way to do it is to somehow get all of the results into a collection.  The problem here is that Collect and ClearCollect are also not delegated so you would have to split your Filter function so that it only collected <2k records at a time.  As an example, suppose you are collecting data over several years and that each year you never collect over 2k records.  

Concurrent( ClearCollect(yr2016, Filter('[dbo].[myTable]', Year(createdDate) = Year(Now()-2),
ClearCollect(yr2017, Filter( '[dbo].[myTable]',Year(createdDate) = Year(Now())-1),
ClearCollect(yr2018, Filter( '[dbo].[myTable]', Year(createdDate) = Year(Now())); Collect(allyears,yr2016);Collect(allyears,year2017);Collect(allyears,year2018)

CountRows(allyears) should give an accurate count all of your records. You could also CountRows on each subcollection ie CountRows(yr2017) and be sure that none of the rows is >2000.  Then sum the CountRows label values. 

View solution in original post

Thanks @Drrickryp. I will work at carving up the data into smaller chunks using Collections.

Take care!

Dhuayb
Frequent Visitor

It is better to use a single column from that table so you will end up not counting the rows but number of items in a column. Therefore an easy fix is to use COUNT(Source.ID). Or in your case, use

Count(
    Filter(
        '[dbo].[myTable]',
        createdDate <= ThisItem.date
    ).ID
)

 This is delegable 

pbil
Regular Visitor

This is great Idea! It worked for me.

Dhuayb
Frequent Visitor

Glad it did

Dhuayb
Frequent Visitor

Glad it worked

seadude
Memorable Member
Memorable Member

I think back in 2018 when I originally posted this, Date-type columns were not delegable. So any Filter query with Date logic would return Delegation error. 

 

I do like your idea of counting a single column rather than all rows. I'll have to pop open Monitor and see if it reduces the response size (which would mean a performance improvement). 

 

Nice call!

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Apps Community Call

Monthly Power Apps Community Call

Did you miss the call?? Check out the Power Apps Community Call here!

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (54,408)