Hello,
I am trying to calculate the sum of all items within a gallery, based on each item's TextInput.Text value. I'm attempting this code to calculate the sum:
Sum( Gallery.AllItems, Value( TextInput.Text ) )
The above code is what I've researched as the best solution, but it doesn't work as expected. Instead of adding each item's TextInput.Text value, it takes the first item's TextInput.Text value and multiplies it by the number of items in the gallery.
Instead of: Sum( {34}, {33}, {33} ) = 100
It actually calculates: Sum( {34}, {33}, {33} ) = 102, or {34} * 3
1. I thought this could be a disambiguation issue, so I tried resolving it from that perspective. No resolution.
2. I thought the data type could be incorrect, but no resolution found.
3. I thought a property within the control might be wrong, no resolution found.
4. I un-nested the control out of a container, so that the TextInput control had the Gallery as its parent. No resolution.
I realize that I could use the OnChange property to Patch() the data source (which is a collection in my case), but I've found that using Patch() freezes the app for a split second while the code is executed, and selection of the control is reset, which disrupts tabbing through the controls, making for a unpleasant user experience.
Does anyone have a reasonable solution for this? Do I have to lower my expectations and use the OnChange property to Patch()?