web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Filter sql table on ba...
Power Apps
Answered

Filter sql table on basis of ID stored in collection

(0) ShareShare
ReportReport
Posted on by 158

Hi All,

 

I have a requirement in which i need to filter Student data on basis of student ID present in one collection. But i am getting delegation warning on filter condition. 

 

Code using:

 

ForAll(
colListofNewAddedStudent As passThrough551,Collect( colExportData,
Filter(Student_Details,Student_ID = Value(passThrough551.student_id))))

 

Thanks in advance

 

 

 

 

 

 

 

Categories:
I have the same question (0)
  • LaurensM Profile Picture
    12,516 Moderator on at

    Hi @ridhan,

     

    Could you try the code below:

    ForAll(
     colListofNewAddedStudent As passThrough551,
     Collect(
     colExportData,
     With(
     {wStudentId: Value(passThrough551.student_id)},
     //Changed to LookUp since I expect there only to be one match when using ID 
     LookUp(
     Student_Details,
     Student_ID = wStudentId
     )
     )
     )
    )

     

    If this solves your question, would you be so kind as to accept it as a solution & give it a thumbs up.

    Thanks!

  • ridhan Profile Picture
    158 on at

    Hi @LaurensM - Thanks you for providing the aboce solution. It worked half way. ACtually i am facing below twqo issues while using above code:

     

    1. There are 50 columns in my table but using above code it is only extracting student ID in the new colllection and not extracting data of rest of the columns which is really strange for me.

     

    2. I can not use the Lookup as i have multiple records of 1 student ID in that table so it needs to pull records for 1 student Id. So i have changed it to Filter again.

     

    ForAll(
    colListofNewAddedStudent As passThrough551,
    Collect(
    colExportData,
    With(
    {wStudentId: Value(passThrough551.student_id)},
    //Changed to LookUp since I expect there only to be one match when using ID
    Filter(
    Student_Details,
    Student_ID = wStudentId
    )
    )
    )
    )

  • AndrewR1 Profile Picture
    1,572 Moderator on at

    Hi can you try this for me: 

     

    ClearCollect(
     colExportData,
     Filter(
     Student_Details,
     Student_ID in colListofNewAddedStudent.student_id
     )
    )
  • AndrewR1 Profile Picture
    1,572 Moderator on at

    Sorry can you try and adjust your flomul to be like this: 

    ClearCollect(
     colExportData,
     AddColumns(
     Filter(
     Student_Details,
     Student_ID in colListofNewAddedStudent.student_id
     ),
     "Selected", true
     )
    );
    Collect(
     colExportData,
     ForAll(
     colExportData,
     {
     wStudentId: Student_ID,
     wStudentData: Filter(colExportData, Student_ID = wStudentId)
     }
     )
    )

     

  • Verified answer
    timl Profile Picture
    37,212 Super User 2026 Season 1 on at

    Hi @ridhan 

    The reason why all the columns don't show is due to the 'explicit column selection' of SQL Server.  You can modify @LaurensM 's formula to include a call to ShowColumns. Here, you would specify the columns that you want to retrieve.

    ForAll(
     colListofNewAddedStudent As passThrough551,
     Collect(
     colExportData,
     With(
     {wStudentId: Value(passThrough551.student_id)},
     ShowColumns(
     Filter(
     Student_Details,
     Student_ID = wStudentId
     ),
     "ColumnYouWantToShow1",
     "ColumnYouWantToShow2",
     "ColumnYouWantToShow3"
     )
    
     )
     )
    )

     

    The alternative is to disable explicit column selection in you app settings. This isn't recommended because it'll have a negative impact on overall performance.

  • ridhan Profile Picture
    158 on at

    Hi @timl @LaurensM - It worked like a charm. Thanks for all your help!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 477

#2
WarrenBelz Profile Picture

WarrenBelz 341 Most Valuable Professional

#3
11manish Profile Picture

11manish 317

Last 30 days Overall leaderboard