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 / Button formulas in Pow...
Power Apps
Answered

Button formulas in Powerapp

(0) ShareShare
ReportReport
Posted on by

Hi Everyone 

 

I have few buttons in my PowerApps, I have set it as a header section for all my screen.

Danny_Dicaprio_0-1706786003436.png

On select of my button Set (SelectedButton,"Home")

on visible of my Landing screen
Set (
SelectedButton,
"Home"
)

 The problem I'm having is that when I Navigate to another screen (not from the Button action), the button that was selected in the Landing screen is set as the default selection in my new screen.

 

 could anyone please help me to fix it? 

Categories:
  • timl Profile Picture
    37,407 Super User 2026 Season 2 on at

    Hi @Danny_Dicaprio 

    I'm not entirely clear as to how you've set this up, but a possible solution is to Set the variable from the other places where you navigate to a different screen. For example:

    Set(
     SelectedButton,
     "Events"
    );
    Navigate(EventScreen)

     

  • Micky Profile Picture
    365 Moderator on at

    It seems to me you're using a context variable, make your variable global by copying your power fx code below to App.OnStart 

    Set (SelectedButton,"Home")

     

    MMPoweR_0-1706793929338.png

     



  • Danny_Dicaprio Profile Picture
    on at

    HI @MMPoweR @timl 

    Thanks for the reply,

    if I try to pass it on the ON start of the button, what happens is the home button will get default selected for all my screens. 

    If I navigate from the home screen with using a button which is not included in the Header section, I don't want the header section button should get selected as defaulted as my previous screen.  (I have same button as header section for all my screens)

     

    Home Screen 

    Danny_Dicaprio_0-1706846963480.png

     

    Screen 2 when I Navigate from screen 1 from a different button.  (Not from selecting "Home Button ")

    Danny_Dicaprio_2-1706847054104.png

     

     

     

  • timl Profile Picture
    37,407 Super User 2026 Season 2 on at

    @Danny_Dicaprio 

     

    >>If I navigate from the home screen with using a button which is not included in the Header section, I don't want the header section button should get selected as defaulted as my previous screen. (I have same button as header section for all my screens)

     

    Can you share the formula that you're using to make the header button purple (which is what I assume you mean when you say that the button is selected)? That will help us to give you the correct answer to this.

  • Danny_Dicaprio Profile Picture
    on at

    HI @timl @MMPoweR 

     

    Thanks for the reply!

    Danny_Dicaprio_0-1706867824488.pngDanny_Dicaprio_1-1706867907838.png

     

     

    If(SelectedButton="Home",RGBA(107, 21, 213, 1),RGBA(255, 255, 255, 1))

     

  • timl Profile Picture
    37,407 Super User 2026 Season 2 on at

    @Danny_Dicaprio 

    On screen 2, if you edit the OnSelect property of the button that takes you to screen 1 like so, that should hopefully resolve the problem.

    Set(SelectedButton,"");
    Navigate(Screen1)

     

  • Danny_Dicaprio Profile Picture
    on at

    hi @timl 

     

    Yeah, but what about if Iam Moving from Screen 1 to Screen 2 

    The screen 2 is not my home screen, but the button "Home" is highlighting as same as screen1,

     

    How do I fix the issue  

  • Verified answer
    timl Profile Picture
    37,407 Super User 2026 Season 2 on at

    @Danny_Dicaprio 

    If you're moving from Screen 1 to Screen 2 and you don't want the "Home" button to be highlighted, you would use this formula on Screen1 to navigate to Screen 2.

    Set(SelectedButton,"");
    Navigate(Screen2)

     

  • Danny_Dicaprio Profile Picture
    on at

    Thanks @timl   That would solve the issue! 

    I was just making it more complex. 

     

  • Micky Profile Picture
    365 Moderator on at

    For the Home button, add this on the OnSelect property.

    Set(SelectedButton,"HomeScreen");
    Navigate(HomeScreen)

    For the Home button, add this on the Fill property.

    If(SelectedButton = "HomeScreen",RGBA(0, 100, 100, 100),RGBA(56, 96, 178, 1))

     

    For the Event button, add this on the OnSelect property.

     

    Set(SelectedButton,"EventScreen");
    Navigate(EventScreen)

     

    For the Event button, add this on the Fill property.

     

    If(SelectedButton = "EventScreen",RGBA(0, 100, 100, 100),RGBA(56, 96, 178, 1))

     

    Do this to all your screens that has Home and Event button.

     

     

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

#2
WarrenBelz Profile Picture

WarrenBelz 207 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 169

Last 30 days Overall leaderboard