Fixed: "Behavior Function in a Non-Behavior Property" in Power Apps
You type a formula with Set, Navigate or Patch into a property, and Power Apps underlines it in red: Behavior function in a non-behavior property. The formula isn't wrong as such; it's in the wrong place. Functions that do something can only run when something happens, such as a button being selected.
The Error
The example put a Set into App.Formulas, where named formulas live:

Behavior function in a non-behavior property. You can't use this property to change values elsewhere in the app.
Studio also reported 1 formula errors exist within the formula. Press F8 to access.
What It Means
Power Apps has two kinds of properties:
| Kind | Examples | What the formula does |
|---|---|---|
| Behavior properties | OnSelect, OnVisible, OnHidden, OnStart | Runs actions when something happens |
| Everything else (data flow) | Text, Visible, Fill, Items, App.Formulas | Calculates a value, again whenever its inputs change |
Microsoft's formula guide explains that functions such as Navigate and Collect can only be used in behavior formulas; in a property that expects a value, such as Text, Visible or Fill, they're flagged as an error. Set, Patch, Notify and the other state-changing functions are in the same group.
The error says it plainly: a value property "can't change values elsewhere in the app".
The Fix
If you wanted a value: make it a named formula
LoadCount = Set(gblLoadCount, 1); was really trying to define a value. In App.Formulas, a value is written directly:
LoadCount = 1;
In the example, the line was simply removed, and the error went with it:

See How to Use Named Formulas in Power Apps.
If you need an action: move it to a behavior property
When something really should change at a moment in time, put the formula in a behavior property, such as a button's OnSelect. The same Set is accepted there:
Set(gblLoadCount, 1)

In the example, Studio reported No formula errors present afterwards. (It was a test; the button's OnSelect was set back to its original value.)
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
| Navigate in a Text or Visible formula | This error | Put it in OnSelect |
| Set in App.Formulas to "initialize" a value | This error | Write a named formula: Name = value; |
| Patch to save when a value changes, in Text | This error | Save from a button's OnSelect |
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| The error on App.Formulas | A behavior function in a named formula | Rewrite as a value, or move it |
| The error on a control property | The property expects a value | Use the control's On... property |
| Not sure which property you're in | The property list shows it | Check the box to the left of the formula bar |
FAQ
Which properties are behavior properties?
The ones whose names start with On: OnSelect, OnVisible, OnHidden, OnStart, OnChange and so on.
Can I run an action when a value changes?
Not from the value's own formula. Use the OnChange of an input control, or an event like OnSelect.
Is this the same as App.OnStart?
OnStart is a behavior property, so Set is allowed there. Microsoft recommends named formulas instead for values; see What the Enable App.OnStart Property Setting Does in Power Apps.
Conclusion
Behavior function in a non-behavior property means an action is in a property that calculates a value. Turn it into a value, or move it to an On... property.
Additional Resources
- Get started with formulas: manage app behavior: which functions are behavior-only.
- Understand behavior formulas: the full rules.
