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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Filtered gallery of a ...
Power Apps
Answered

Filtered gallery of a collection with two lookup functions

(0) ShareShare
ReportReport
Posted on by 30

Hi all,

 

I have 2 important collections,

base_collection

 

Base Collection
MaterialSystemQuantity
Material-1System-140
Material-2System-240
Material-3System-240
Material-4System-340
Material-1System-240
Material-6Equipo-740

 

which is where I get all the data, search_collection,

 

Search Collection
MaterialSystemQuantity
Material-1System-135
Material-2System-235

 

a collection that the user inputs and contains the data they are looking for in the base_collection.

What do I need? I need a gallery that filters the combination of material and system from the search_collection and searches for it in the base_collection, and then displays the filtered gallery:

 

Filtered Gallery
MaterialSystemQuantity
Material-1System-140
Material-2System-240

 

I tried using this code:

 

Filter(
 base_collection,
 And(
 MasterID.ECAPP_Hdr_opt1 = GalleryHdrDetails_2.Selected.ECAPP_Hdr_opt1,
 item_material = LookUp(
 search_collection,
 Row_CDMaterial = base_collection[@cr56a_material],
 item_material
 ),
 item_system = LookUp(
 search_collection,
 Row_system = base_collection[@cr56a_equipo],
 item_system
 )
 )
)

 

, but it only gives me this gallery:

 

Actual Gallery  
MaterialSystemQuantity
Material-1System-140
Material-2System-240
Material-3System-240
Material-1System-240

 

What I understand is that it searches for either the same material or the same system, but what I need is for it to search for the unique combination of material and system.

Categories:
I have the same question (0)
  • RogierE Profile Picture
    875 Moderator on at

    I guess the approach with filling a Collection would get you a better outcome:

     

    Clear(colOutcome);
    ForAll (colSearchCollection,
    Collect(colOutcome,Filter(colBaseCollection,Material=colSearchCollection[@Material],System=colSearchCollection[@System])))

     

    Please LIKE the reply and ACCEPT it as the solution if the answer is what you were looking for.
    (to help me grow in community rank and help others find the solution)

  • Santiago241 Profile Picture
    30 on at

    Hi @RogierE

     

    This is colBaseCollection

    Santiago241_0-1712237455765.png

    This one is colSearchCollection

    Santiago241_1-1712237681084.png

     

     

     

    and this one is colOutcome 

    Santiago241_2-1712237766307.png

    I created the collection using the code you recommended, but I'm getting the same result :(.

    I don't know how to solve this problem.

     

     

  • Verified answer
    RogierE Profile Picture
    875 Moderator on at

    Hard for me to check what you did wrong if you only share the outcome 🙂 

     

    Before I sent you the suggestion, I checked to see if it worked. I created a mockup App with only a single button, and this piece of code in the OnSelect: 

     

    ClearCollect(colBaseCollection,
    [{Material:1,   System:1,   Quantity:40},
    {Material:2,    System:2,   Quantity:40},
    {Material:3,    System:2,   Quantity:40},
    {Material:4,    System:3,   Quantity:40},
    {Material:1,    System:2,   Quantity:40},
    {Material:6,    System:7,   Quantity:40}]);

    ClearCollect(colSearchCollection,
    [{Material:1,   System:1,   Quantity:35},
    {Material:2,    System:2,   Quantity:35}]);

    Clear(colOutcome);

    ForAll (colSearchCollection,
    Collect(colOutcome,Filter(colBaseCollection,Material=colSearchCollection[@Material],System=colSearchCollection[@System])))
     
    Works like a bliz, and gives the expected outcome.
    RogierE_0-1712260680938.png

     

    Would it be an idea to add this full piece of code to a button, press it and see that it works as requested? Then maybe you can compare that with what you did exactly...
     
    Please LIKE the reply and ACCEPT it as the solution if the answer is what you were looking for.
    (to help me grow in community rank and help others find the solution)
  • Santiago241 Profile Picture
    30 on at

    Ty @RogierE  😁

  • RogierE Profile Picture
    875 Moderator on at

    Did you find the difference? 

  • Santiago241 Profile Picture
    30 on at

    In the end it was my own mistake because I didn't pass my collections correctly, but it's working now, thanks :).

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard