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 / Filtering before doing...
Power Apps
Answered

Filtering before doing a Lookup

(0) ShareShare
ReportReport
Posted on by 16

Hi All,

 

Does anyone know how I can filter a list before doing a Lookup? Basically I want to maximize performance by removing unnecessary lookup calls.

 

List1

ID - Name

 

List2

ID - List1ID - Status - OtherColumns

 

I would like to filter List2 on records which Status = Active, and then do the lookup on ID against List1

 

Thanks!

Categories:
  • AmirBakht Profile Picture
    262 on at

    If you are doing a lookup on a unique ID you are pretty much optimized, you won't need to filter first, that would actually bring down the performance. 

    This is my understanding.

  • ChamCR Profile Picture
    16 on at

    Thanks, Amir, but the problem resides not on List1 where the ID is unique, but on List2 which the List1ID is repeated multiple times, thus the reason for first filtering on Status

  • AmirBakht Profile Picture
    262 on at

    My bad. Here's something you can do,

     

    LookUp(Filter(List2, Status = "Active"), List1ID = YourID)

     

    Just remember LookUp gets the first value it finds and not the others if there are more that meet the filter criteria. 

    PS. I just text wrote that so make sure the formula is correct, but that should give you the gist of it.

  • v-yutliu-msft Profile Picture
    Microsoft Employee on at

    Hi @ChamCR ,

    Could you tell me:
    1)the relationship between list1 and list2?

    2)the data type of List1ID field, Status field?

    3)the filter rule in details, especially "do the lookup on ID against List1"?

    I assume that :
    List1ID field is a lookup field(not allow multiple value), which looks up to ID field in List1 

    Status is a choice field

    The filter rule:
    use a drop down to select ID in list1, filter list2 based on selected ID

     

    If so, you could set like this:
    1)drop down's Items:

    List1

    2)the table for filtered list2:

    Filter(List2,Status.Value="Active",List1ID.Value=dropdownname.Selected.ID)

    Then the table will display items that status is active and list1ID value is equal to the selected ID.

     

     

    Best regards,

     

  • ChamCR Profile Picture
    16 on at

    Hi!

     

    • Columns are not of type Lookup in Sharepoint.
    • The ID columns are both numeric (integers)
    • The Status column is a string (Active, Inactive)

     

    So the ultimate goal is to be able to merge/join both lists into a single one, and only for the records that have an Active status in List2

     

    In SQL I would have written something like:

     

    SELECT List1.Name, List2.Status, List2.OtherColumns

    FROM List1

    INNER JOIN List2

    ON List1.ID = List2.List1ID

    WHERE List2.Status = 'Active'

     

    Thanks

     

  • Verified answer
    v-yutliu-msft Profile Picture
    Microsoft Employee on at

    Hi @ChamCR ,

    Do you want to create a new table with data from list1 and list2?

    If so, what you need is not to filter items, you need to use AddColumns() function to reshape table.

    Try this formula:

     

    ClearCollect(mergedcollection,
    AddColumns(
     Filter(List2,Status="Active"),
     "Name","")
    );
    //create a new collection with the data of List1 and a new field named Name
    ForAll(List1,
     Patch(mergedcollection,
     LookUp(mergedcollection,List1ID=ID),
     {Name:List1[@Name]}
     )
     )
    //update mergedcollection by using Name field of List1
    

     

    Then mergedcollection will be the table that merges/joins both lists.

     

     

    Best regards,

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 224 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 189 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 126

Last 30 days Overall leaderboard