Showing results for 
Search instead for 
Did you mean: 
Advocate V
Advocate V

Filtering data from multiple tables

Can we filter SQL table based on the values from another table(like a join in SQL)?


We have two tables Table1_UserPermission["PersonID","ProjectID","IsActive"], Table2_ProjectDetails["ProjectID","ProjectName","ProjectCost"].


When the user logs in, we are trying to check the Table1_UserPermission table first for the active projects using the PersonID. Then project details data from Table2_ProjectDetails will be displayed in a gallery for the user active projects from Table1_UserPermission.

Responsive Resident
Responsive Resident

Hi @DileepGolla

I would normally produce local collections of the active projects for the current user in Table1, and then use that to filter the list of projects in Table2.

Something like:

ClearCollect(colUserPermissions, Filter(Table1_UserPermission, PersonID=currentUserID && IsActive=true));
ClearCollect(colUserProjects, Filter(Table2_ProjectDetails, ProjectID in colUserPermissions.ProjectID))

The variable 'currentUserID' is from however you determine what the current user's ID number is.

colUserProjects becomes your Gallery.Items source.

Hope this helps.


Hi Hadyn,


Thank you for taking out time and responding to my question.


I have tried the approach you have suggested but it gives a delagating warning when I try to use "in" operator.


Even if I ignore the delagation warning, the collection is empty. Are you facing the same issue? Or am I missing something obvious?

Responsive Resident
Responsive Resident

A few things to check:

  • Is the currentUserID set to a valid ID number? (One that has 'active' projects in Table1)
  • Is there data in the colUserPermissions collection?



HI Hadyn,


Yes I can see the data collected in the first collection and also there is data in all the required columns in both the tables.




Responsive Resident
Responsive Resident

Hmmmm, not sure on that one.  It may be a delegation issue.

Alternatively, since you are using SQL, a stored procedure could return the results you need.  I often do this for more complicated queries with lots of joins or where there are thousands of records to filter from.


A step-by-step guide by @Mr-Dang-MSFT is available here:



Community Support
Community Support

Hi @DileepGolla,

Could you please share a bit more about the data structure of your two SQL tables?

Is the IsActive column a Bit type column in your Table1_UserPermission table?

Further, have you faced a Delegation Warning issue with the in operator within your formula?

I have made a test on my side, please take a try with the following workaround:

Set the OnVisible property of the first screen of your app to following:

ClearCollect(UserPermissionCollection, Filter(Table1_UserPermission, PersonID = currentUserPersonID, IsActive = true))

Set the Items property of the Gallery to following:

Filter(Table2_ProjectDetails, ProjectID in UserPermissionCollection.ProjectID)

then check if the issue is solved.


In addition, the in operator could be delegated within SQL table data source, please check the following article for more details:

please share more details about the Delegation warning issue within your app.

As an alternative solution, in order to get rid of the Delegation warning issue, please consider take a try with the following workaround:

Set the OnVisible property of the first screen of your app to following:

ClearCollect(UserPermissionCollection, Filter(Table1_UserPermission, PersonID = currentUserPersonID, IsActive = true));
ClearCollect(ProjectDetailsCollection, Table2_ProjectDetails)

Set the Items property of the Gallery to following:

Filter(ProjectDetailsCollection, ProjectID in UserPermissionCollection.ProjectID)

 Also please check if your Table2_ProjectDetails table contains the ProjectID column, and have prorper records for current user with specific ProjectID Value.


In addition, 

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.
Not applicable

Thanks for creating this thread @DileepGolla. Can you review the latest replies and advise if they answer your question or if you need more assistance?


Thank you,



Helpful resources

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


Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Did you miss the call? Check out the recording here!

Top Solution Authors
Top Kudoed Authors
Users online (26,028)