cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Filter Variable

Hi,

 

I have been trying to find a solution for my PowerApp and have researched a lot to find a solution but no luck...

 

I have three screens in my PowerApp and the second screen depends on what button is clicked on the first screen. On my third screen, I have a list that is used to filter stuff on the second screen. Everything seems to work fine, it's just that when I go back to my first screen (main page) and click another button to go to the second screen the filter still remains and filters the list accordingly.

 

So, just to make it more clear what can I do for the filter variable to be blank when I go back to the main screen. Hopefully, what I said above is not that confusing. Let me know if I should elaborate more. Thanks in advance. Would really appreciate if someone can help me with this.

 

Kind Regards,

Usman

1 ACCEPTED SOLUTION

Accepted Solutions
Mike8
Level 10

Re: Filter Variable

Hello Usman,

Can you please try on screen 2, instead of what you have now, this:
Back Arrow: UpdateContext({SelectedPlatform:""});Navigate(HomeScreen,ScreenTransition.Fade)

View solution in original post

21 REPLIES 21
Power Apps Staff ShantanuP
Power Apps Staff

Re: Filter Variable

The filter that you have on third screen, what does it operate on? If I understand then the behavior that you want is filter should work only when specific button is pressed on first screen. If this is correct then you can use context variable to set on button.OnSelect on first screen as part of navigate function 

Navigate(Screen2, ScreenTransition.Cover, {A:true})

 

When you navigate back to screen 1, you can reset this value to false.

UpdateContext({A: false});Navigate(Screen1, ScreenTransition.Cover)

 

Then you can use this variable value to choose what the result of filter is.

For example,

If(A, Filter(...))

 

I hope this helps you.

Anonymous
Not applicable

Re: Filter Variable

Hi,

 

Thank you for your response. No, the filter does not actually relate to the first screen. My second screen depends on my third screen (filter screen) but when I go back to my screen 1 (main screen) that filter still remains. Let me explain a bit better:

 

This is my first screen:

1.PNG

 

 

When you click on one of the buttons it comes up with the following screen (screen 2):

 

2.PNG

 

When I click the filter button on the top right, I get the following screen to chose one of the filters (screen 3):

3.PNG

 

And finally when I click one of the arrows it goes back to the screen 2 - with the filter applied:

4.PNG

 

Now I can click clear filter to remove the filter which works perfectly fine. But what I want is that if the user clicks the back arrow to go to the main screen without clearing the filter, following image:

5.PNG

 

How can I get that filter applied removed when the user goes back to the main screen, as the filter still remains.

 

Hopefully, this was clear. Thank you so much. 🙂

 

Kind Regards,

Usman.

Mike8
Level 10

Re: Filter Variable

Hello Usman,

Try to take whatever is in the OnSelect property of the clear filter and added to OnSelect property of the left arrow icon.
Does it work if you do that?

Anonymous
Not applicable

Re: Filter Variable

Hi,

 

No, it does not work.

 

This is what I have on the clear filter: Navigate(ServicesScreen, ScreenTransition.Fade,{SelectedPlatform: ""})

 

And this is what I have on the Back Arrow: Navigate(HomeScreen,ScreenTransition.Fade,{SelectedPlatform: ""})

 

Just a note: SelectedPlatform is the name of the variable that stores the value of the filter from screen 3

 

Thanks.

Usman.

Power Apps Staff ShantanuP
Power Apps Staff

Re: Filter Variable

The context variables are scoped to the screen. So Navigate(ServicesScreen, ScreenTransition.Fade,{SelectedPlatform: ""}) adds context variable SelectedPlatform on ServicesScreen which has differenrent value than the one in HomeScreen. What you should do is to use an app variable instead which is global. You can set this app variable on OnVisible of home screen to reset it. 

Power Apps Staff ShantanuP
Power Apps Staff

Re: Filter Variable

You can set app variable using Set function. For example, Set(SelectedPlatform, "")

Anonymous
Not applicable

Re: Filter Variable

Hi,

 

I get your point but how do I set the variable to global. Following is the code that I am using my filter screen:

 

Navigate(ServicesScreen, ScreenTransition.Fade,{SelectedPlatform: FilterLabel.Text})

 

So, do you mean to say do this:

 

Navigate(ServicesScreen, ScreenTransition.Fade,Set(SelectedPlatform, FilterLabel.Text))

 

I get an error in the code above.

 

I even tried it with the following code on Service screen but got an error for this(back button):

 

Navigate(HomeScreen,ScreenTransition.Fade,Set(SelectedPlatform, ""))

 

Lastly, this is the code that I am using on each button for my home screen:

 

Navigate(ServicesScreen, ScreenTransition.Fade,{SelectedVertical: "Agribusiness Intelligence"})

 

Not sure if I need to add SelectedPlatform Variable on this as well i.e SelectedPlatform:"" 

 

Thank you so much for the help. I really appreciate this.

 

Kind Regards,

Usman.

 

 

Anonymous
Not applicable

Re: Filter Variable

I did put this code OnVisible for the home screen ' Set(SelectedPlatform, "") ' but the filter still remains

Mike8
Level 10

Re: Filter Variable

Hello Usman,

You need to do it seperately,
The Set function will be after the Navigate() and not inside it, like this:
Navigate(HomeScreen,ScreenTransition.Fade);Set(SelectedPlatform, "").
We will solve it, don't worry. Let me know how I can help.

Helpful resources

Announcements
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 Kudoed Authors (Last 30 Days)
Users online (4,124)