# Updating multiple dataset values

**URL:** <https://forum.inductiveautomation.com/t/updating-multiple-dataset-values/21789>\
**Category:** Ignition\
**Created:** [January 10, 2019, 2:21pm UTC](https://forum.inductiveautomation.com/t/updating-multiple-dataset-values/21789 "2019-01-10T14:21:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![francisco.romero](https://avatars.discourse-cdn.com/v4/letter/f/91b2a8/32.png) [@francisco.romero](https://forum.inductiveautomation.com/u/francisco.romero)\
**Post date:** [January 10, 2019, 2:21pm UTC](https://forum.inductiveautomation.com/t/updating-multiple-dataset-values/21789/1 "2019-01-10T14:21:45Z")

</div>

Hi, I have a script on a numeric label, each time the value changes I do some operations and depending on the result of the operations I update several rows of a table dataset.

What I have now is this:  
if event.propertyName == “value”:  
print “change in performance value”  
updatedRow = system.dataset.updateRow(data, 0,{“Value”:(performance\*100)})  
event.source.parent.getComponent(‘Pie Chart 1’).data = updatedRow  
data = event.source.parent.getComponent(‘Pie Chart 1’).data  
updatedRow = system.dataset.updateRow(data, 1,{“Value”:(1-performance)\*100})  
event.source.parent.getComponent(‘Pie Chart 1’).data = updatedRow

I am reading the dataset and update 1 row, then read again the dataset and update other row and so on …

The solution works, however I am looking for a much efficient solution. Do you have any other ideas?

Thanks!

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 10, 2019, 3:17pm UTC](https://forum.inductiveautomation.com/t/updating-multiple-dataset-values/21789/2 "2019-01-10T15:17:41Z")

</div>

Yes, you should hang onto the intermediate dataset and perform all of the updates on it, then set it back to the component. Something like this:

```auto
if event.propertyName == 'value':
	perf = event.source.newValue
	pchart = event.source.parent.getComponent('Pie Chart 1')
	ds = pchart.data
	ds = system.dataset.updateRow(ds, 0, {'Value': (perf * 100)})
	ds = system.dataset.updateRow(ds, 1, {'Value': ((1.0-perf) * 100)})
	pchart.data = ds

```

{ ps. Use triple-backquotes on lines above and below your pasted code to format it nicely. These: ``` . You could edit your original post to do so. }

---

<div class="post-metadata">

**Author:** ![francisco.romero](https://avatars.discourse-cdn.com/v4/letter/f/91b2a8/32.png) [@francisco.romero](https://forum.inductiveautomation.com/u/francisco.romero)\
**Post date:** [January 10, 2019, 6:36pm UTC](https://forum.inductiveautomation.com/t/updating-multiple-dataset-values/21789/3 "2019-01-10T18:36:21Z")

</div>

Thank you ! it works now.
