Do you use the App onstart to set a lot of variables? And then do you repeat this same within other places of the app to keep things up to date? The new named formulas in App.Formula might be a better option.
To enable Named formulas you can go to the Settings in your app. Then switch on the Named formula feature. Notice that this feature is still experimental, but it is a great feature to try out ( in non production apps)
Named formulas in Power Apps using App.Formulas 2
Configuring Named Formulas
Now you can configure within App.Formulas using lines of code like this:
X = CountRows(List)
Named formulas in Power Apps using App.Formulas 3
It might look like there isn’t much of difference between the Set and the ‘=’ assignment. But there is!
Difference between the Set function and Named Formulas
With the Set function you will set a value to a variable. This means that every time you want the variable to be updated you will have to rerun the code.
With Named functions you don’t have to do this. As your data changes ( in my example the datasource List), the value given by the Named function will automatically change. So in the earlier example as the List is updated and refreshed, the value of X will automatically be updated too.
That is one thing less to worry about in your app.
Is your business still running on paper trails, sprawling Excel files, or ageing Access databases? There's a better way — and I can show you exactly what it looks like.
I'm the Technical Director of Vantage 365, a Microsoft solutions consultancy working with clients across the UK, the Netherlands, and worldwide.
For over 30 years I've been turning messy, manual business processes into clean, automated systems that save time, reduce errors, and give teams the visibility they need to make better decisions.
SharePains is not just any blog run by a Microsoft MVP. Have you ever used Try-Catch in Power Automate? The original post about Try-Catch in Power Automate can still be found on this site, https://sharepains.com/2018/02/07/try-catch-finally-in-power-automate-flow/
Or have you ever used the Pieter’s method to avoid variables and speed up your flows? https://sharepains.com/2020/03/11/pieters-method-for-advanced-in-flows/
You can contact me using contact@sharepains.com
Is your business still running on paper trails, sprawling Excel files, or ageing Access databases? There's a better way — and I can show you exactly what it looks like.
I'm the Technical Director of Vantage 365, a Microsoft solutions consultancy working with clients across the UK, the Netherlands, and worldwide.
For over 30 years I've been turning messy, manual business processes into clean, automated systems that save time, reduce errors, and give teams the visibility they need to make better decisions.
SharePains is not just any blog run by a Microsoft MVP. Have you ever used Try-Catch in Power Automate? The original post about Try-Catch in Power Automate can still be found on this site, https://sharepains.com/2018/02/07/try-catch-finally-in-power-automate-flow/
Or have you ever used the Pieter’s method to avoid variables and speed up your flows? https://sharepains.com/2020/03/11/pieters-method-for-advanced-in-flows/
You can contact me using contact@sharepains.com
Thanks Peter I like how you’ve explained this, just to validate I have this right. Could I use this instead of a setting a selected item in a gallery via variable and do something like ItemId = gallery.selected.ID?
That would certainly be the intention to reduce the code required in different locations around the app on various controls where possible. Would be much easier to maintain. Thanks Peter
Great post on one of the latest released features. Thanks for the break down!
Thanks Peter I like how you’ve explained this, just to validate I have this right. Could I use this instead of a setting a selected item in a gallery via variable and do something like ItemId = gallery.selected.ID?
Yes, that would indeed be a possible use of named variables. I am not sure if it would speed up the app but at least the code is shorter.
That would certainly be the intention to reduce the code required in different locations around the app on various controls where possible. Would be much easier to maintain. Thanks Peter