Showing results for 
Search instead for 
Did you mean: 

Define original variable

Link 1:


Link 2:


PowerApps seems to be confused with variable definitions. In Link 1, users of PA are noting that their navigation formulas are not working because the variable passed is encountering errors even though they had not edited the app. In Link 2, I reported that PA slows down when you are in the middle of typing a formula for an existing variable. Both problems have to do with the definition of a variable. It is not clear to us how PowerApps prioritizes definitions of variables--is there a hierarchy we can view?


I am suggesting that there be a location in PA where you could define a variable and the kind of data it is validated for. When typing formulas, PA would check against that original definition as a priority. Uses of the variable that match that original definition will be okay while anything that does not match the original definition would appear with the yellow sign. 


So if you are in the middle of typing a formula:

Set(variable, tr...)

and the variable already exists elsewhere for taking boolean values, you would normally break every control that references the variable since they no longer think it takes boolean values. If you have an original definition that takes precedence, everything that relies on the variable would not have yellow error signs; only the most recent formula that doesn't match the original definition would have the error.


I predict that this would resolve performance issues described in Link 2 since the original definition would remain strong. I think it would also avoid issues with passing variables between screens as described in Link 1 (though I still recommend Set() instead of passing variables).


Is this doable? What is the existing hierarchy for which definition of a variable is prioritized?

Status: New
PowerApps Staff

This is a good idea. Thanks for posting this. What you are suggesting is technically feasible, but would be limiting when compared to the existing solution.

Currently you can define variables in multiple places and the types will be merged(if possible, error otherwise) For Example, you can say Set(x,{col1:3, col2:true}) on one place and Set(x,{col3:"some text"}) in other place. the combined type of x will be {col1:number, col2:boolean,col3:text}

We will review your suggestion.

Level 10

Hi @Hemanth,

Thank you for sharing how the variables work together--that is golden information and the method sounds ideal. Does the same merger work with Collections?

PowerApps Staff

Yes. the types of collections are merged the same way. As things are collected into collections as a result of some user behaviors, the columns not defined in that action will have null values for that row value.