SetFocus function in Power Apps

Today I came across the SetFocus function and a few until now hidden functions in Power Apps as Microsoft updated the Function reference document.

The SetFocus documentation dates from 2019 so the function must have existed before so it has just been hidden away for a while.

Then when I had a play with this SetFocus function I bumped into a few other nice features.


SetFocus can be used to set the focus of your app to a specified control. Although hidden for a long time, this is one of the useful functions in Power Apps that will make your UX a lot better.

In the app below depending on which button I click I can force the cursor to go to one of my input boxes.

SetFocus, one of the hidden functions in Power

There will be plenty of apps where for example a choice or a toggle needs to make the focus of the app change.

An other great example is, if you have an input box and the user has to click on a button to submit the data in the input box then the SetFocus can keep the focus on the input box whereas usually the focus will change to the the button.

IsType and AsType

The IsType will let you check if your record is of a certain entity. The AsType you can use to typecast your entity. These functions in Power Apps are mainly important if you use Dynamics 365 or the Common Data Service (CDS)

For example when you have a Customer record in your CDS then you could treat this as an Account or as a Contact. Now you can force the code to go into the right direction of the right entity.


Self is not a function even though it has been included in the function reference! Self is used to reference the control that you are currently working with inside the Power Apps Studio.

As you can see below there are no brackets after Self.

6 hidden functions in Power Apps until today Microsoft Office 365 image 45

In the app below the PressedFill is set to Self.Fill. This is very close to the point where we can set the colour of something by using some code like :

Set(Self.Fill, RGBA(100,100,100,1))

But that is not how PowerApps works. So how can we use Self?

You can now use Self to use any part of the control to set another property. Like the above PressedFill is using the Fill. In the past this code would have been TextInput1.Fill.

For more information on Self see also

SetProperty & Trace

The SetProperty you can use to set a property of a control. The trace function can be used to add information to your test result. This is not a function that you can use in a Canvas Power App. You can however us this in the test app in Power Apps Test Studio.

In described test apps in the past please read my post about testing apps for more information.


The last one of the functions that has been added to the functions reference is With. An interesting example is given on the docs page referenced.

6 hidden functions in Power Apps until today Microsoft Office 365 interest calculator
With( { AnnualRate: RateSlider/8/100, // slider moves in 1/8th increments and convert to decimal 
       Amount: AmountSlider*10000, // slider moves by 10,000 increment 
       Years: YearsSlider, // slider moves in single year increments, no adjustment required 
       AnnualPayments: 12 }, // number of payments per year 
      With( { r: AnnualRate/AnnualPayments, // interest rate 
              P: Amount, // loan amount n: 
              Years*AnnualPayments }, // number of payments 
       r*P / (1 - (1+r)^-n) // standard interest calculation 

This example shows quite nicely how data is massaged before it is being used. How often do you write expressions, that have the same bit repeated over and over again? With the with function you can quite easily avoid that.

Avatar for Pieter Veenstra

By Pieter Veenstra

Business Applications Microsoft MVP working as a Principal Architect at HybrIT Services Ltd. You can contact me using

7 thoughts on “6 hidden functions in Power Apps until today”
  1. The SetFocus is amazing, but it doesn’t work inside a form (like a SharePoint form or a gallery). Have you found a solution to do this inside the form? i.e. I have a form with multiple “tabs”, so when I change tabs, I’d like the form to scroll back up to the top.

  2. Not being able to setFocus to an input field in a form or gallery is seriously the stupidest thing by Microsoft – not at all 508 compliant.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from SharePains by Microsoft MVP Pieter Veenstra

Subscribe now to keep reading and get access to the full archive.

Continue Reading

%d bloggers like this: