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 Apps
Answered

Filter Variable

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

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

Categories:
  • ShantanuP Profile Picture
    Microsoft Employee on at

    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.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    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 Profile Picture
    1,330 on at

    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?

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    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.

  • ShantanuP Profile Picture
    Microsoft Employee on at

    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. 

  • ShantanuP Profile Picture
    Microsoft Employee on at

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

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    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.

     

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

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

  • Mike8 Profile Picture
    1,330 on at

    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.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Mike8,

     

    Thank you. I tried what you said but the filter still remains.

     

    This is the code I have on the back button to homepage:

     

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

     

    Also, I even have this for OnVisible on the home screen:  Set(SelectedPlatform, "")

     

    But the filter still persists... not sure why.

     

    Thanks again.

    Usman.

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

#2
WarrenBelz Profile Picture

WarrenBelz 202 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 122

Last 30 days Overall leaderboard