cancel
Showing results for 
Search instead for 
Did you mean: 

Patch - Referance a column name via a variable

Is that possible to make PowerApps can refer to a column via a variable?

 

I want to use "Patch" function to update column in Data Source. But the number of columns to be updated and columns name is not fixed. So it would be great of PowerApps to allow dynamically refer to a column.

 

 

For example, is it possible to replace the "DataField_8" below with dynamic variable such as "Dropdown2.Selected.Value"?

 

 
Patch(dbo_Update, LookUp(dbo_Update, ProductCode=Dropdown1.Selected.Value), {
    DataField_8 : TextInput1.Text
})
Status: Under Review

We hear you and appreciate your patience.  Unfortunately this is not easy for us to do.  Unlike VBA and other languages, Power Apps is strongly typed and named - everything is well established at compile time.  It's one of the fundamental principles of the product.  This allows us to detect more errors, optimize, and provide better intellisense during authoring.

 

Can you tell us more about the scenarios in which this would be helpful?  Some examples with code would be great.  Perhaps we can find a solution that addresses the need without making field names fully dynamic.

Comments
Frequent Visitor

This would be an extremely useful feature.  I've spent a full day trying to find a more efficient way to accomplish something and it turns out my 'hack' (massive Switch formula) is the best approach.  Especially frustrating as the referenced column structure in my app is somewhat fluid* so I have to update the formula every-time we add a column or consolidate columns.

 

*We are trying to normalize the various customer questionnaires our teams use (multiple redundancies and differences in term definitions) into a single SharePoint list.  The App allows users to select the form they want to use and it only displays the questions relevant to them (with answers pre-populated if someone already asked the question in a different forum).  Over time we plan to consolidate questions (columns) and add new questions (columns) as new requirements arise

New Member

Using dynamic column names will not violate you beautiful world defined by “Power Apps is strongly typed and named - everything is well established at compile time.” The reason is simple, column names are strings, so any variable of type string can be used as a column name. Simple to incorporate in PowerApps world. No?