I have a collection (ColGridData) with 40 columns, and I'm trying to sum the 2 columns and put the results into 3rd. The first field is a dropdown, the second field is a numeric field, and the results goes into the third. The user could manually enter the data into either Boost or 'Final Weight'.
Ideal scenario is when the user changes either the 'Weight' or 'Boost' the 'Final Weight' would be updated to 7.
I will give an example code and setup in Power Apps to achieve your requirements. You can refer this to make adjustments in your app.
Considering, you have data/columns like below in your ColGridData
:
ClearCollect(
ColGridData,
{
Weight: 3,
Boost: 4,
FinalWeight: ""
},
{
Weight: 4,
Boost: 5,
FinalWeight: ""
}
)
Used above collection as items
property of the gallery control - which contains 3 more controls inside it: 1 drop down and 2 text inputs:
Dropdown control setup (Weight):
Items
property:
Table({Value: 1},{Value: 2},{Value: 3},{Value: 4},{Value: 5})
Default
property:
ThisItem.Weight
First text input control (Boost):
Default
property:
ThisItem.Boost
Second text input control (Final Weight):
Default
property:
ThisItem.FinalWeight
Now, use below formulas to update the FinalWeight
column in collection when you change the Boost or Weight field values:
Set OnChange
property of drop down control (Weight) and first text input control (Boost) to:
Patch(
ColGridData,
ThisItem,
{FinalWeight: Value(ddWeight.Selected.Value) + Value(txtBoost.Text)}
)
Output: