cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
smoli
New Member

Filtering a gallery by the items from another gallery

Hi, 

I would like some help on the following scenario if something has any idea. As a summary I wan to filter one gallery by the items from another gallery.

 

I have an app with 3 galleries: Name, Country, City. 

There are also two tables, Table_Name Name+Countries and another,Table_City, with Country+City.

 

When I select a name in the gallery Name (This is just a distinct on Table_Name by name) I want:

  1. Gallery Country to display the countries associated to that name
  2. Gallery City to display the cities associated to that country. 

Step 1 is easy to achieve just with a filter in Items as Filter(colmycountries,name=Gallery1.Selected.Result)

Step 2 is more complex when I have 2 or more items. In that case it is filtering only by the first element. This is my attempt Filter(colmycities,country=Gallery1_1.Selected.country)

 

Image1: Expected result

smoli_1-1623757175031.png

Image2: Unexpected result ("london" is missing from the tables)

smoli_0-1623757138961.png

 

The solution I'm thinking is I may need to do a For All (All items in Gallery Country), Collect the result in a new Collection, and put this new collection in the items property for the gallery City? 

 

Is there any other idea?

 

Many thanks

 

1 ACCEPTED SOLUTION

Accepted Solutions
Ethan_R
Resolver III
Resolver III

Hi @smoli ,

You can try this, does it give all results as you expected or any error ?

Filter(colmycities,country in Gallery1_1.AllItems)

 

Hope this helps

View solution in original post

2 REPLIES 2
Ethan_R
Resolver III
Resolver III

Hi @smoli ,

You can try this, does it give all results as you expected or any error ?

Filter(colmycities,country in Gallery1_1.AllItems)

 

Hope this helps

View solution in original post

Thanks @Ethan_R  it worked. I eventually made it work with the ForAll(Collect) option above in the "On Select" property in the First Gallery, but that way is easier to implement. 

 

Clear(colmyFilteredItems);
ForAll(Gallery1_1.AllItems,
    Collect(colmyFilteredItems,Filter(colmycities,country=Label1_1.Text))
)

 

Thanks again, for some reasons I always forget about the "in" command :). 

Helpful resources

Announcements
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

secondImage

Demo Extravaganza Winner Announcement

Please join us on Wednesday, July 21st at 8a PDT. We will be announcing the Winners of the Demo Extravaganza!

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (3,368)