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 / Variable that referenc...
Power Apps
Answered

Variable that references to App.Width does reevaluate on App.Width change

(0) ShareShare
ReportReport
Posted on by 160

Hi All,

I am not sure I got this right, maybe for the App.Width this might not work but I thought that Variables in PowerApps when referenced with a value that changes will be updated as well.

I am trying to make a scaling formula that I need to use everywhere so I can just pass a variable instead of placing the formula everywhere.
It is something like this at App Start

Set(_scale, 16+(40-16)*((App.Width - App.MinScreenWidth) / (Last(FirstN(App.SizeBreakpoints, 3)).Value - App.MinScreenWidth)

 

Any ideas what I doing wrong? I tried disabling non blocking and delayed load. That did not change a thing.

Categories:
I have the same question (0)
  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @rssilvaba 

    Variables are ALWAYS snapshots in time.  They do not update until you update them.

    You can consider what I call a "dynamic variable".  For this, place a label in your app - Let's call it lblScale and set the Text property to the following:

    16+(40-16)*(
     (App.Width - App.MinScreenWidth) / 
     (Last(FirstN(App.SizeBreakpoints, 3)).Value - App.MinScreenWidth)
    )

    Now, this label will change dynamically as any of the items it the formula change.

    You can reference this anywhere in your app with Value(lblScale.Text)

     

     I hope this is helpful for you.

  • rssilvaba Profile Picture
    160 on at

    Hi @RandyHayes ,

    That is very clever "hack".
    I will give it a try and accept, It seems the right thing to do, especially that my app has only one screen, so should work everywhere.

  • Verified answer
    RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @rssilvaba 

    Yes, this works perfectly and quite honestly, we use this approach 100 times over variables.  Variables never change, the concept is that controls are global in PowerApps and will automatically change based on their formulas...so, why not use that concept!

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 765 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 272

Last 30 days Overall leaderboard