Showing results for 
Search instead for 
Did you mean: 
Level: Powered On

Filter SQL data source by collection of ids

I won't include the whole of my app/db details but hopefully enough so that you get the gist of what I'm trying to do.

I have two tables (using Azure Sql),



Id: int
Name, Email, etc.


Id: int

ContactId: int

Name, email, etc.


I have a collection of Contacts (colContacts) and I want to get the PAs (colPAs) for each of these contacts. I want to achieve this in a single call to the database, rather than use a ForAll. This is the line of code I am trying to use:


Collect(colPAs, Filter('[dbo].[PA]', contact_id =;


But I get an 'invalid argument type' error, as well as a delegation warning.


I was trying to use:


Collect(colPAs, Filter('[dbo].[PA]', contact_id in;


But I also get a delegation warning. And I just realised that using In might return 20 when the id is 2, etc.


Is there some way to achieve what I'm trying to do, i.e. Filter by a collection of Ids?


Any ideas?



Dual Super User
Dual Super User

Re: Filter SQL data source by collection of ids

Hi @DE1 


Can you try to modify your expression as:
Collect(colPAs, Filter('[dbo].[PA]', contact_id exactin;
Also, regarding the delegation, please update your settings as:
File -> App Settings -> Advanced Settings -> Look for Data Rows Limit for Non-Delegable queries -> Update this to 2000.
If you have less than 2000 rows then the warning will go away.
Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
Community Support Team
Community Support Team

Re: Filter SQL data source by collection of ids

Hi @DE1 ,

How many records stored in your PA Table? More than 2000?

Do you want to filter your PA Table records based on the colContacts?


Based on the needs that you mentioned, I think the second formula you provided could achieve your needs.


If the amount of your PA Table records is not more than 2000, I think you could ignore this Delegation warning issue. Please consider set the "Data row limit for Non-delegable queries" option to maximum value -- 2000 within the Advanced settings of App settings of your app, then you could process 2000 records locally at most in your app, then try your second formula again, check if the issue is solved.

More details about the Delegation in PowerApps, and how to change the limit, please check the following article:


If the amount of your PA Table records is more than 2000, please check and see if the alternative solution mentioned within the following thread would help in your scenario:

On your side, please take a try with the following workaround:

Set the OnStart property of the App control to following (I assume that there are 10000 records stored in your PA Table😞

           ClearCollect(col1, Filter('[dbo].[PA]', Id >= 1 && Id  <= 2000)),
           ClearCollect(col2, Filter('[dbo].[PA]', Id  >= 2001 && Id  <= 4000)),
           ClearCollect(col3, Filter('[dbo].[PA]', Id  >= 4001 && Id  <= 6000)),
           ClearCollect(col4, Filter('[dbo].[PA]', Id  >= 6001 && Id  <= 8000)),
           ClearCollect(col5, Filter('[dbo].[PA]', Id  >= 8001 && Id  <= 10000))
ClearCollect(MergedCollection, col1, col2, col3, col4, col5)

Then modify your formula as below:

Collect(colPAs, Filter(MergedCollection, contact_id in

Note: I assume that the Id column is a auto-increment unique type column in your PA Table.

Please consider take a try with above solution, then re-load your app (fire the OnStart property of the App), check if the issue is solved.


Best regards,

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

Helpful resources


Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!


Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020


Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Kudoed Authors (Last 30 Days)
Users online (4,240)