cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
araelius86
Level: Powered On

Filter based on previous selected Variable.

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


1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Filter based on previous selected Variable.

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

View solution in original post

4 REPLIES 4
Super User
Super User

Re: Filter based on previous selected Variable.

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

View solution in original post

araelius86
Level: Powered On

Re: Filter based on previous selected Variable.

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
Level: Powered On

Re: Filter based on previous selected Variable.

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
Level: Powered On

Re: Filter based on previous selected Variable.

Never mind this. I solved with Gallery2.selected.

 

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (4,748)