# Possible to populate a Power Table from a script?

**URL:** <https://forum.inductiveautomation.com/t/possible-to-populate-a-power-table-from-a-script/46268>\
**Category:** Ignition\
**Created:** [May 3, 2021, 2:01pm UTC](https://forum.inductiveautomation.com/t/possible-to-populate-a-power-table-from-a-script/46268 "2021-05-03T14:01:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dmiessner](https://avatars.discourse-cdn.com/v4/letter/d/77aa72/32.png) [@dmiessner](https://forum.inductiveautomation.com/u/dmiessner)\
**Post date:** [May 3, 2021, 2:01pm UTC](https://forum.inductiveautomation.com/t/possible-to-populate-a-power-table-from-a-script/46268/1 "2021-05-03T14:01:02Z")

</div>

As the title says I was curious if it was possible to populate a power table from a script.

Essentially there is some data that I would like to manipulate before displaying it into the Power Table, and the easiest way that I can think of wouldn’t be through an SQL query, but rather a short script that can ensure that the data is what I expected it to be.

Would anyone know of a way that I can do this?

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [May 3, 2021, 2:21pm UTC](https://forum.inductiveautomation.com/t/possible-to-populate-a-power-table-from-a-script/46268/2 "2021-05-03T14:21:39Z")

</div>

Sure, here is an example I stole from the manual…

```auto
headers = ["City", "Population", "Timezone", "GMTOffset"]
data = []
 
data.append(["New York", 8363710, "EST", -5])
data.append(["Los Angeles", 3833995, "PST", -8])
data.append(["Chicago", 2853114, "CST", -6])
data.append(["Houston", 2242193, "CST", -6])
data.append(["Phoenix", 1567924, "MST", -7])

tableData = system.dataset.toDataSet(headers, data)

event.source.parent.getComponent('Power Table').data = tableData

```

That shows you can write to a table via a script. You can run your SQL query in a script as well. Link in case you need it:  
[https://docs.inductiveautomation.com/display/DOC81/Queries+in+Scripting](https://docs.inductiveautomation.com/display/DOC81/Queries+in+Scripting)

---

<div class="post-metadata">

**Author:** ![dmiessner](https://avatars.discourse-cdn.com/v4/letter/d/77aa72/32.png) [@dmiessner](https://forum.inductiveautomation.com/u/dmiessner)\
**Post date:** [May 3, 2021, 2:22pm UTC](https://forum.inductiveautomation.com/t/possible-to-populate-a-power-table-from-a-script/46268/3 "2021-05-03T14:22:21Z")

</div>

Ah this is exactly what I was looking for!

Thank you very much!
