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 / Filter based on previo...
Power Apps
Answered

Filter based on previous selected Variable.

(0) ShareShare
ReportReport
Posted on by 37

Hi,

 

I am trying to build an app off one list of variables. 

On the first screen I have a list of departments populated from the Sharepoint list.

The items formula for Gallery1 looks like this 

 

Distinct('Customer Services Branch Phone List', Department)

 

I have buttons next to each populated department with formula

Set(Variable, ThisItem);Navigate(NameList, Fade)

My problem begins with populating a second gallary off the selection from the first.

I need help with the formula to populate gallery2 with only the Names of the people that are associated with the Department chosen in Gallery1

Many thanks


Categories:
  • Verified answer
    RusselThomas Profile Picture
    4,014 on at

    Hi araelius86,

     

    Can you confirm what the content of the vairable is once you've pushed the button? (Use the Variables option under View menu).

     

    Distinct returns a table with a single column by default titled "Result".    

    If you Set(variable, ThisItem) then the variable is likely to be a row of data (again, even if it's only one column it's still constructed as a row).

     

    Constructed as above, to access the value I suspect you might need to use variable.Result

     

    To filter another gallery with the same data by the variable you would set the Items to

    Filter('Customer Services Branch Phone List', Department=variable.Result)

     

    Alternatively, you could change your Set() function to

    Set(variable, Thisitem.Result)

    in which case you can access the value just by using variable.

     

    Filter('Customer Services Branch Phone List', Department=variable)

    That said, you can simply use the Gallery.Selected option and avoid the variable entirely (although if you plan to use it elsewhere in your app you may still want it).  This assumes your buttons for each row are actually inside the gallery card and not outside.

     

    For this, just set the button to 

     

    Navigate(NameList, Fade)

    And in the Items property of the second gallery

    Filter('Customer Services Branch Phone List', Department=Gallery1.Selected.Result)

     

    Hope this helps 🙂

     

    Kind regards

    RT

  • araelius86 Profile Picture
    37 on at

    Thanks Russel,

     

    That second lot of formulas worked.

    I have a third screen in which I want to display the details of the Person selected from the NameList.

     

    Would it be a similar formula for the item input?

  • araelius86 Profile Picture
    37 on at

    In addition,

     

    I want to be able to search in either namelist or Gallery1 for a name and have it display the 3rd page named "Detail Screen1_2"

    I have distinct as a function on the gallery because my list has the department for each person and if I auto populate the Gallery1 it duplicates the Department for every name in the list.

     

    Is there a better way to display the Departments only once?

  • araelius86 Profile Picture
    37 on at

    Never mind this. I solved with Gallery2.selected.

     

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 432 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 347

#3
WarrenBelz Profile Picture

WarrenBelz 254 Most Valuable Professional

Last 30 days Overall leaderboard