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 / 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:
I have the same question (0)
  • 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

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