cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Resolver I
Resolver I

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

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Super User III
Super User III

@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!

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

3 REPLIES 3
Super User III
Super User III

@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.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

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.

Super User III
Super User III

@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!

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

Helpful resources

Announcements
News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

Power Apps Community Call

Power Apps Community Call- January

Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST

PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

Top Solution Authors
Top Kudoed Authors
Users online (3,440)