cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Filter Gallery by ID of different sources

Hey Everyone,

 

I need to filter a gallery of source A by the Item ID compared with the input Value of a field in source C && another input Value of source C and the Item ID of source B.

 

In Source A i have my material

In Source B i have my Events

In Source C i have the ID of the material and the ID of the event it belongs to.

 

Now i would like to present the material based on the users selection of the Event.

 

Thank you in advance for your attention.

2 ACCEPTED SOLUTIONS

Accepted Solutions

Hey Magnifica,

 

  I think that I've got a solution that will work for you. Inside your gallery, you're going to want to set its "Items" property similar to:

Filter(Materials,ID in Filter(Relations,EventID=EventDropdown.Selected.ID).MaterialID).MaterialName

 

Below is an example that helps explain what is going on in the above statement. The example should also help explain what the various values are and how they correspond to the data you are working with.

 

First, I've set up three collections that I think roughly match the data you're working with:

ClearCollect(Materials, {ID: "1", MaterialName: "MaterialName1"}, {ID: "2", MaterialName: "MaterialName2"}, {ID: "3", MaterialName: "MaterialName3"});
ClearCollect(Events, {ID: "1", EventName: "EventName1"}, {ID: "2", EventName: "EventName2"}, {ID: "3", EventName: "EventName3"});
ClearCollect(Relations, {ID: "1", MaterialID: "2", EventID: "3"}, {ID: "2", MaterialID: "3", EventID: "1"}, {ID: "3", MaterialID: "1", EventID: "2"})

We've got:

 

  • a "Materials" collection, whose entries have an "ID" and a "MaterialName" (Note: this corresponds to "Source A" in your post)
  • an "Events" collection, whose entries have an "ID" and an "EventName" (Note: this corresponds to "Source B" in your post)
  • a "Relations" collection, whose entries have an "ID", a "MaterialID" and an "EventID" (Note: this corresponds to "Source C" in your post)

 

Next, I've created a "Drop down" control to allow the user to select an event by its "EventName":

  1. Create a "Drop down" control
  2. Set its "Items" property to "Events" (Note: this would correspond to "Source B" in your post)
  3. In the "Advanced" sidebar, set the "Value" under "Items" to "EventName". This will cause the "Drop down" to display entries containing an "EventName".

Finally, create a "Vertical Text" gallery to display our related materials:

  1. Create a "Vertical Text" gallery
  2. Set its "Items" property to 
    Filter(Materials,ID in Filter(Relations,EventID=EventDropdown.Selected.ID).MaterialID).MaterialName

Let's break down the various parts of this "Items" statement. We'll start with the innermost statement and move outwards. I'll replace parts of the statement we've already looked at with an "X" to limit clutter.

 

EventDropdown.Selected.ID

This is referencing the "ID" field of the "Event" record we selected from our "Drop down".

 

Filter(Relations,EventID=X).MaterialID

Here, we filter the "Relations" table, grabbing any records with an "EventID" that match the value we selected in our "Drop down". The last bit tells it we're only interested in the "MaterialID" field of the filtered records.

 

Filter(Materials,ID in X).MaterialName

Finally, we filter the "Materials" table, grabbing any records with an "ID" that matches one of the "MaterialID"s we filtered in the previous step. Similar to last time, we're only interested in the "MaterialName" field.

 

With all this in place, whenever the "Drop down" is changed, we should see our gallery update to display a list of "Materials" which are related to the chosen "Event".

Let me know if you have any questions,

  Maxwell, PowerApps-Staff

View solution in original post

Hey Magnifica,

 

  There's a couple small changes we can make to the previous example to get this extra data to display.

 

  First, we're going to have to modify the items property of our gallery to return the whole record and not just the material name. We'll do this by removing the ".MaterialName" from the end of the property's value.

Filter(Materials,ID in Filter(Relations,EventID=EventDropdown.Selected.ID).MaterialID)

Because of this, there might be a few places in your gallery where you need to tell it specifically to display the "MaterialName" now. You should be able to do this through the sidebar UI when you have the gallery or one of the gallery entries selected.

 

Next, you'll want to make sure you still have the gallery selected. In my previous example, we were using a text gallery, so each gallery entry has a Body, Heading and Subtitle. Chances are good that the "Body" property of this gallery (over in the Sidebar UI) says something like "MaterialName". We're going to change the body of each entry to display the quantity of the material associated with our selected event.

 

  1. Click on the text field immediately below "Body" (in the sidebar UI)
  2. Enter the following for its value:
    LookUp(Relations, MaterialID=ThisItem.ID && EventID=EventDropdown.Selected.ID).Quantity

Let's go over what we're doing here. First, you'll notice that we're using "LookUp()" and not "Filter()". The difference between the two is that "LookUp()" will return a single record while `Filter()` returns a table of records. In our case, I believe a specific combination of "MaterialID" and "EventID" to be unique. In this case, we can use "LookUp()" instead of "Filter" to avoid having to get the filtered record out of a table later. Some more information about these two functions (as well as "Search") can be found here: https://powerapps.microsoft.com/en-us/tutorials/function-filter-lookup/

 

Next, we're saying we want the record we find to have a "MaterialID" equal to "ThisItem.ID". In this case, "ThisItem" refers to the record being referenced by any given entry in our gallery. This is why we removed ".MaterialName" in the previous step; we were going to need to access the record's "MaterialID" field.

 

After that, we've got a familiar looking condition. We're making sure the relational entry we select shares an "EventID" with the one selected from our drop down. I figured that there might be multiple relational entries with the same "MaterialID", this ensures we only get the entry relevant to the event we've selected.

 

Finally, we tell it that we are only interested in the "Quantity" field of the specified record.

 

Hope that helps,

  Maxwell, PowerApps-Staff

View solution in original post

7 REPLIES 7

Hey Magnifica,

 

  I think that I've got a solution that will work for you. Inside your gallery, you're going to want to set its "Items" property similar to:

Filter(Materials,ID in Filter(Relations,EventID=EventDropdown.Selected.ID).MaterialID).MaterialName

 

Below is an example that helps explain what is going on in the above statement. The example should also help explain what the various values are and how they correspond to the data you are working with.

 

First, I've set up three collections that I think roughly match the data you're working with:

ClearCollect(Materials, {ID: "1", MaterialName: "MaterialName1"}, {ID: "2", MaterialName: "MaterialName2"}, {ID: "3", MaterialName: "MaterialName3"});
ClearCollect(Events, {ID: "1", EventName: "EventName1"}, {ID: "2", EventName: "EventName2"}, {ID: "3", EventName: "EventName3"});
ClearCollect(Relations, {ID: "1", MaterialID: "2", EventID: "3"}, {ID: "2", MaterialID: "3", EventID: "1"}, {ID: "3", MaterialID: "1", EventID: "2"})

We've got:

 

  • a "Materials" collection, whose entries have an "ID" and a "MaterialName" (Note: this corresponds to "Source A" in your post)
  • an "Events" collection, whose entries have an "ID" and an "EventName" (Note: this corresponds to "Source B" in your post)
  • a "Relations" collection, whose entries have an "ID", a "MaterialID" and an "EventID" (Note: this corresponds to "Source C" in your post)

 

Next, I've created a "Drop down" control to allow the user to select an event by its "EventName":

  1. Create a "Drop down" control
  2. Set its "Items" property to "Events" (Note: this would correspond to "Source B" in your post)
  3. In the "Advanced" sidebar, set the "Value" under "Items" to "EventName". This will cause the "Drop down" to display entries containing an "EventName".

Finally, create a "Vertical Text" gallery to display our related materials:

  1. Create a "Vertical Text" gallery
  2. Set its "Items" property to 
    Filter(Materials,ID in Filter(Relations,EventID=EventDropdown.Selected.ID).MaterialID).MaterialName

Let's break down the various parts of this "Items" statement. We'll start with the innermost statement and move outwards. I'll replace parts of the statement we've already looked at with an "X" to limit clutter.

 

EventDropdown.Selected.ID

This is referencing the "ID" field of the "Event" record we selected from our "Drop down".

 

Filter(Relations,EventID=X).MaterialID

Here, we filter the "Relations" table, grabbing any records with an "EventID" that match the value we selected in our "Drop down". The last bit tells it we're only interested in the "MaterialID" field of the filtered records.

 

Filter(Materials,ID in X).MaterialName

Finally, we filter the "Materials" table, grabbing any records with an "ID" that matches one of the "MaterialID"s we filtered in the previous step. Similar to last time, we're only interested in the "MaterialName" field.

 

With all this in place, whenever the "Drop down" is changed, we should see our gallery update to display a list of "Materials" which are related to the chosen "Event".

Let me know if you have any questions,

  Maxwell, PowerApps-Staff

Thank you so much!! Its exactly what i was searching for. And the explanation was great.

 

One more question.

In the Relations collection i have one column with quantaty (of the material)

This i want to present in a field next to the MaterialName. How could I achieve that?

 

 

Thanks in advance! 

Hey Magnifica,

 

  There's a couple small changes we can make to the previous example to get this extra data to display.

 

  First, we're going to have to modify the items property of our gallery to return the whole record and not just the material name. We'll do this by removing the ".MaterialName" from the end of the property's value.

Filter(Materials,ID in Filter(Relations,EventID=EventDropdown.Selected.ID).MaterialID)

Because of this, there might be a few places in your gallery where you need to tell it specifically to display the "MaterialName" now. You should be able to do this through the sidebar UI when you have the gallery or one of the gallery entries selected.

 

Next, you'll want to make sure you still have the gallery selected. In my previous example, we were using a text gallery, so each gallery entry has a Body, Heading and Subtitle. Chances are good that the "Body" property of this gallery (over in the Sidebar UI) says something like "MaterialName". We're going to change the body of each entry to display the quantity of the material associated with our selected event.

 

  1. Click on the text field immediately below "Body" (in the sidebar UI)
  2. Enter the following for its value:
    LookUp(Relations, MaterialID=ThisItem.ID && EventID=EventDropdown.Selected.ID).Quantity

Let's go over what we're doing here. First, you'll notice that we're using "LookUp()" and not "Filter()". The difference between the two is that "LookUp()" will return a single record while `Filter()` returns a table of records. In our case, I believe a specific combination of "MaterialID" and "EventID" to be unique. In this case, we can use "LookUp()" instead of "Filter" to avoid having to get the filtered record out of a table later. Some more information about these two functions (as well as "Search") can be found here: https://powerapps.microsoft.com/en-us/tutorials/function-filter-lookup/

 

Next, we're saying we want the record we find to have a "MaterialID" equal to "ThisItem.ID". In this case, "ThisItem" refers to the record being referenced by any given entry in our gallery. This is why we removed ".MaterialName" in the previous step; we were going to need to access the record's "MaterialID" field.

 

After that, we've got a familiar looking condition. We're making sure the relational entry we select shares an "EventID" with the one selected from our drop down. I figured that there might be multiple relational entries with the same "MaterialID", this ensures we only get the entry relevant to the event we've selected.

 

Finally, we tell it that we are only interested in the "Quantity" field of the specified record.

 

Hope that helps,

  Maxwell, PowerApps-Staff

Hello Mexwell,

 

Amazing, exactly what i was looking for! Thank you - it works perfectly.

If i now would want to have the option to delete an item from the Relation collection with a X icon. How would it look like to do so? 

Hey Magnifica,

 

  A similar question has already been answered here: https://powerusers.microsoft.com/t5/PowerApps-Forum/delete-screen-confirmation/td-p/26204

  Please note that this implementation also displays a confirmation screen before allowing the user to delete a record. Since deleting a record is a potentially destructive action, I believe this is a good idea. It will help prevent a user from accidentally deleting a record.

 

  A quick summary about the linked answer:

  1. It adds a "Delete" button to this gallery.
  2. This button navigates to a secondary, confirmation screen with two buttons.
  3. On this confirmation screen, if the "Yes" button is clicked, the record is deleted and the app navigates back to the primary screen.
  4. On this confirmation screen, if the "No" button is clicked, nothing is deleted and the app navigates back to the primary screen.

 

Let me know if you want further clarification on the linked answer,

  Maxwell, PowerApps-Staff

for the post and the explanation.

 

I would like to add new items to the Relation collection. How do i get the right connected Event ID and Materiel ID?

 

- I want to open an excisting Event and add new Matreials to this event (means i want to add items to the relation collection with ID of the Materiel and the amount)

 

- I wan to have add a new Event set date location etc and Materials to this event (items to the relation collection with ID of the Materiel and the amount)

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!   This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions in the Forums to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersNumber of SolutionsSuper UsersNumber of Solutions @anandm08  23 @WarrenBelz  31 @DBO_DV  10 @Amik  19 AmínAA 6 @mmbr1606  12 @rzuber  4 @happyume  7 @Giraldoj  3@ANB 6 (tie)   @SpongYe  6 (tie)     Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersSolutionsSuper UsersSolutions @anandm08  10@WarrenBelz 25 @DBO_DV  6@mmbr1606 14 @AmínAA 4 @Amik  12 @royg  3 @ANB  10 @AllanDeCastro  2 @SunilPashikanti  5 @Michaelfp  2 @FLMike  5 @eduardo_izzo  2   Meekou 2   @rzuber  2   @Velegandla  2     @PowerPlatform-P  2   @Micaiah  2     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 3:Community MembersSolutionsSuper UsersSolutionsPower Apps anandm0861WarrenBelz86DBO_DV25Amik66Michaelfp13mmbr160647Giraldoj13FLMike31AmínAA13SpongYe27     Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 4:Community MembersSolutionsSuper UsersSolutionsPower Apps DBO-DV21WarranBelz26Giraldoj7mmbr160618Muzammmil_0695067Amik14samfawzi_acml6FLMike12tzuber6ANB8   SunilPashikanti8

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages