cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sarahmahony
Helper I
Helper I

Filter Gallery Based by Data from Previous Gallery

Hi Powerapps Community,

 

I have two gallery screens that I would like to nest. The first gallery ('UID Selection Gallery') shows the company names and then once clicked, I would like second gallery ('Gallery2') to show all the company's employee representatives. 

 

I currently have a distinct and filter by user function on the 'UID Selection Gallery' and the same filter by user function on the 'Gallery2'. These codes need to be included. 

UID Selection Gallery currently: 

 

Search(Distinct(Filter('VOC Customer List_ Test File Clean_V2',(AccountManagerEmail=varUserEmail|| sales_mgr_email=varUserEmail||sales_dir_email=varUserEmail||state_dir_email=varUserEmail)),Title&": "&reg_name),'UID Search Box'.Text,"Result")

 

Gallery2 currently: 

 

Filter('VOC Customer List_ Test File Clean_V2',(AccountManagerEmail=varUserEmail|| sales_mgr_email=varUserEmail||sales_dir_email=varUserEmail||state_dir_email=varUserEmail))

 

 

Data source: 'VOC Customer List_ Test File Clean_V2'

Gallery 1: UID Selection Gallery

Gallery 2: Gallery2

Column name required for filter: Title

 

Any help would be appreciated! error2.png

1 ACCEPTED SOLUTION

Accepted Solutions
Drrickryp
Super User
Super User

@sarahmahony 

I think I see the issue here.  Once you use Distinct() you lose the ability to filter on Title for your second gallery. There may be other ways to do this but I found that this one should work without the need for using Distinct().

 

//First, filter your list and create a temporary table "fltrd"
With(    
    {fltrd: Filter( 
                     'VOC Customer List_ Test File Clean_V2',
                         Or(AccountManagerEmail=varUserEmail,
                           sales_mgr_email=varUserEmail,
                           sales_dir_email=varUserEmail,
                           state_dir_email=varUserEmail
             )
//Then, add temp column and group on it to provide uniqueness without losing 
// the rest of the data
//Then, sort on the new temp column and ungroup the rest of the data
//into a temporary table (tbl), that expose the Title in the gallery
      tbl: Ungroup(                                           
            Sort(
                GroupBy(
                    AddColumns(
                               fltrd,"tempcol",Concatenate(
                                                            Title,": ", reg_name
                                                )
                    ),
                    "tempcol", "restofdata"
                ),
                grouper
            ),
            "restofdata"
        )
    },
//Allows for the search of "tbl" with your Textbox. 
    Search(
        tbl,
        'UID Search Box'.Text,
        "Title"
    )
)

 

In your second gallery you can now reference Title to filter your list:

 

Filter(
        VOC Customer List_ Test File Clean_V2', Title=Gallery1.Selected.Title,
                                                Or(
                                                   AccountManagerEmail=varUserEmail,
                                                   sales_mgr_email=varUserEmail,
                                                   sales_dir_email=varUserEmail,state_dir_email=varUserEmail
                                                 )
)

As perhaps a more elegant way of doing this, the exact same formula for Gallery1 could be used as the items property of a dropdown and Gallery2 could be Filtered on the dropdown instead of Gallery1.  This would take up much less real estate in your app.

 

View solution in original post

2 REPLIES 2
Drrickryp
Super User
Super User

@sarahmahony 

I think I see the issue here.  Once you use Distinct() you lose the ability to filter on Title for your second gallery. There may be other ways to do this but I found that this one should work without the need for using Distinct().

 

//First, filter your list and create a temporary table "fltrd"
With(    
    {fltrd: Filter( 
                     'VOC Customer List_ Test File Clean_V2',
                         Or(AccountManagerEmail=varUserEmail,
                           sales_mgr_email=varUserEmail,
                           sales_dir_email=varUserEmail,
                           state_dir_email=varUserEmail
             )
//Then, add temp column and group on it to provide uniqueness without losing 
// the rest of the data
//Then, sort on the new temp column and ungroup the rest of the data
//into a temporary table (tbl), that expose the Title in the gallery
      tbl: Ungroup(                                           
            Sort(
                GroupBy(
                    AddColumns(
                               fltrd,"tempcol",Concatenate(
                                                            Title,": ", reg_name
                                                )
                    ),
                    "tempcol", "restofdata"
                ),
                grouper
            ),
            "restofdata"
        )
    },
//Allows for the search of "tbl" with your Textbox. 
    Search(
        tbl,
        'UID Search Box'.Text,
        "Title"
    )
)

 

In your second gallery you can now reference Title to filter your list:

 

Filter(
        VOC Customer List_ Test File Clean_V2', Title=Gallery1.Selected.Title,
                                                Or(
                                                   AccountManagerEmail=varUserEmail,
                                                   sales_mgr_email=varUserEmail,
                                                   sales_dir_email=varUserEmail,state_dir_email=varUserEmail
                                                 )
)

As perhaps a more elegant way of doing this, the exact same formula for Gallery1 could be used as the items property of a dropdown and Gallery2 could be Filtered on the dropdown instead of Gallery1.  This would take up much less real estate in your app.

 

sarahmahony
Helper I
Helper I

@Drrickryp You're amazing! Thank you!

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (1,870)