# Create a list from one column in a power table

**URL:** <https://forum.inductiveautomation.com/t/create-a-list-from-one-column-in-a-power-table/21139>\
**Category:** Ignition\
**Created:** [November 29, 2018, 4:56pm UTC](https://forum.inductiveautomation.com/t/create-a-list-from-one-column-in-a-power-table/21139 "2018-11-29T16:56:23Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [November 29, 2018, 4:56pm UTC](https://forum.inductiveautomation.com/t/create-a-list-from-one-column-in-a-power-table/21139/1 "2018-11-29T16:56:23Z")

</div>

I’m trying to extract the values from only one column in a power table, create a dataset from it and write it to a tag. Basically, I want to trim the table dataset to the first column only. thanks

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [November 29, 2018, 5:05pm UTC](https://forum.inductiveautomation.com/t/create-a-list-from-one-column-in-a-power-table/21139/2 "2018-11-29T17:05:05Z")

</div>

Where is the table getting its data from?  
If it is a SQL query, you would be better off just creating the tag with a query of that column.  
If it isn’t from a query then we can work up some code for you.

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [November 29, 2018, 5:59pm UTC](https://forum.inductiveautomation.com/t/create-a-list-from-one-column-in-a-power-table/21139/3 "2018-11-29T17:59:17Z")

</div>

it is a manually made dataset, no bindings

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [November 29, 2018, 6:17pm UTC](https://forum.inductiveautomation.com/t/create-a-list-from-one-column-in-a-power-table/21139/4 "2018-11-29T18:17:52Z")

</div>

```auto
tbl = event.source.parent.getComponent('Power Table')
tempDS = system.dataset.toPyDataSet(tbl.data)
hdr = ['Field']
newDS = []
for row in tempDS:
	newDS.append([row[0]])
system.tag.write('PathToDatasetTag',system.dataset.toDataSet(hdr,newDS))

```

---

<div class="post-metadata">

**Author:** ![jpark](https://avatars.discourse-cdn.com/v4/letter/j/a88e57/32.png) [@jpark](https://forum.inductiveautomation.com/u/jpark)\
**Post date:** [November 29, 2018, 6:32pm UTC](https://forum.inductiveautomation.com/t/create-a-list-from-one-column-in-a-power-table/21139/5 "2018-11-29T18:32:42Z")

</div>

Use this function.

[https://docs.inductiveautomation.com/display/DOC79/system.dataset.filterColumns](https://docs.inductiveautomation.com/display/DOC79/system.dataset.filterColumns)

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [November 29, 2018, 6:35pm UTC](https://forum.inductiveautomation.com/t/create-a-list-from-one-column-in-a-power-table/21139/6 "2018-11-29T18:35:48Z")

</div>

That works, thanks. Let me ask another question though. Right now I am manually creating the original power table’s dataset. on the property change event on the table I update the dataset tag, which you helped me with. Now, I want to take the dataset tag and use it to populate another table, in another window, using the tag as the headers for the table. the table should have only one row with all blanks. Would I be better off trying to do all this with a db table and queries?

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [November 29, 2018, 7:09pm UTC](https://forum.inductiveautomation.com/t/create-a-list-from-one-column-in-a-power-table/21139/7 "2018-11-29T19:09:24Z")

</div>

Okay I’m getting close. When I run this code it sets the headers from the rows of the filtered data, but it displays as [u’element1’] instead of just element 1. What am I missing?

```auto
table = event.source.data
col = ['Element Name']
filter = system.dataset.filterColumns(table,col)
pyData = system.dataset.toPyDataSet(filter)
headers = []
dataOut = []
for row in pyData:
	headers.append([row[0]])	

system.tag.write("[Client]RegularElements", system.dataset.toDataSet(headers, dataOut))

```

---

<div class="post-metadata">

**Author:** ![jpark](https://avatars.discourse-cdn.com/v4/letter/j/a88e57/32.png) [@jpark](https://forum.inductiveautomation.com/u/jpark)\
**Post date:** [November 29, 2018, 8:37pm UTC](https://forum.inductiveautomation.com/t/create-a-list-from-one-column-in-a-power-table/21139/8 "2018-11-29T20:37:43Z")

</div>

```auto
if event.propertyName == "data":
	data = event.newValue
	columns = ['t_stamp',"ElementName"]
	filteredDataset = system.dataset.filterColumns(data,columns)
	
	system.tag.write("[Client]RegularElements", filteredDataset)

```
