# Reseting table data

**URL:** <https://forum.inductiveautomation.com/t/reseting-table-data/17368>\
**Category:** Ignition\
**Created:** [March 14, 2018, 7:55pm UTC](https://forum.inductiveautomation.com/t/reseting-table-data/17368 "2018-03-14T19:55:09Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![carolineuchoa.estuda](https://avatars.discourse-cdn.com/v4/letter/c/ba8739/32.png) [@carolineuchoa.estuda](https://forum.inductiveautomation.com/u/carolineuchoa.estuda)\
**Post date:** [March 14, 2018, 7:55pm UTC](https://forum.inductiveautomation.com/t/reseting-table-data/17368/1 "2018-03-14T19:55:09Z")

</div>

Hello!

Is it possible to create a button to reset the table data that is recorded until that moment, and start picking up new data from the time I press the button? In other words, I have a table recording 1 hour of realtime data, I want to press a button so that everything from that hour gets erased and it starts to record data from that moment. Could someone help me, please?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![mrogers](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mrogers/32/4110_2.png) [@mrogers](https://forum.inductiveautomation.com/u/mrogers)\
**Post date:** [March 14, 2018, 8:03pm UTC](https://forum.inductiveautomation.com/t/reseting-table-data/17368/2 "2018-03-14T20:03:35Z")

</div>

Are you just trying to delete all the rows in the dataset but keep the column headers? There are a couple of ways to do this:

```auto
clearedDataSet = system.dataset.toDataSet([HeadersList], [])

```

or

```auto
clearedDataSet = system.dataset.clearDataset(OldDataset) #New in 7.9.7

```

or

```auto
clearedDataSet = system.dataset.deleteRows(OldDataset, range(OldDataset.rowCount))

```

---

<div class="post-metadata">

**Author:** ![carolineuchoa.estuda](https://avatars.discourse-cdn.com/v4/letter/c/ba8739/32.png) [@carolineuchoa.estuda](https://forum.inductiveautomation.com/u/carolineuchoa.estuda)\
**Post date:** [March 15, 2018, 7:22pm UTC](https://forum.inductiveautomation.com/t/reseting-table-data/17368/3 "2018-03-15T19:22:33Z")

</div>

Could you evolve the code a little more? I tried to use what you told, but I couldn’t make it work. So I tried this:

table = event.source.parent.getComponent(‘Table’)  
header = [‘t\_stamp’,‘PIDT1’,‘PIDT2’,‘PIT1’,‘PIT2’,‘ZIT1’,‘ZIT2’]  
row = []  
data = system.dataset.toDataSet(header,row)  
table.data = data

and everything that happens is that the table erases everything, it’s just a blank table, except the headers. It stays erased for about 1 second, and then the table reappears with all old rows values. I needed something like… set all the rows values to 0, for example… in order to get the new realtime values. Could you help me?

---

<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:** [March 15, 2018, 7:25pm UTC](https://forum.inductiveautomation.com/t/reseting-table-data/17368/4 "2018-03-15T19:25:46Z")

</div>

If the data is coming from a binding (DB query, presumably), then you need a script that will modify the data at the source (the DB) or change the parameters of the SQL query. You’ll have to show us the binding you currently have.

---

<div class="post-metadata">

**Author:** ![carolineuchoa.estuda](https://avatars.discourse-cdn.com/v4/letter/c/ba8739/32.png) [@carolineuchoa.estuda](https://forum.inductiveautomation.com/u/carolineuchoa.estuda)\
**Post date:** [March 15, 2018, 7:40pm UTC](https://forum.inductiveautomation.com/t/reseting-table-data/17368/5 "2018-03-15T19:40:39Z")

</div>

Yes, the data is coming from the DB

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/8/87943562d3e1bcbdf9879f4ee9d87ffeb157e38f.png)

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/4/46cdbafae0fabd1454f9c1d4d6b8df637c7b8347.png)

---

<div class="post-metadata">

**Author:** ![carolineuchoa.estuda](https://avatars.discourse-cdn.com/v4/letter/c/ba8739/32.png) [@carolineuchoa.estuda](https://forum.inductiveautomation.com/u/carolineuchoa.estuda)\
**Post date:** [March 15, 2018, 7:57pm UTC](https://forum.inductiveautomation.com/t/reseting-table-data/17368/6 "2018-03-15T19:57:19Z")

</div>

Or maybe if it’s less complex, I could use a 2 state toggle to set when I want the table to write data or not. For example, I press the button to “ON” state, at 2pm, and it records until I press the button again, at 3 pm. Then, I press it again at 8 pm. The table just shows data from 2 to 3 pm then from 8 pm to something. Is this easier for you to help?

---

<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:** [March 15, 2018, 8:08pm UTC](https://forum.inductiveautomation.com/t/reseting-table-data/17368/7 "2018-03-15T20:08:41Z")

</div>

Well, the historian doesn’t have any script support for deleting history, so you’ll have to do it with a post-filter. I would move the history binding to a custom property (`rawData`, perhaps) and add a Date as another custom property (`startDate`, perhaps), then bind the table data with a filter on `startDate`. I’d use the [view() function](https://www.automation-pros.com/simaids/doc/expression.view.html) from [Simulation Aids](https://inductiveautomation.com/moduleshowcase/module/automation-professionals-llc-simulation-aids), though it could be done with a propertyChange event instead. Something like this (expression binding on `data`):

```auto
view("Select * Where t_stamp >= args[0]",
 {Root Container.Table.rawData},
 {Root Container.Table.startDate})

```

Then have your button’s script assign the current timestamp to `startDate` to hide past data.

---

<div class="post-metadata">

**Author:** ![carolineuchoa.estuda](https://avatars.discourse-cdn.com/v4/letter/c/ba8739/32.png) [@carolineuchoa.estuda](https://forum.inductiveautomation.com/u/carolineuchoa.estuda)\
**Post date:** [March 16, 2018, 7:18pm UTC](https://forum.inductiveautomation.com/t/reseting-table-data/17368/8 "2018-03-16T19:18:16Z")

</div>

I’m getting this error

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/5/5f518b18c0a25c5c12317ea442a151babca5e8e8.png)

---

<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:** [March 16, 2018, 7:36pm UTC](https://forum.inductiveautomation.com/t/reseting-table-data/17368/9 "2018-03-16T19:36:00Z")

</div>

Did you make rawData a Dataset? And did you move your binding from data over to rawData?

---

<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:** [March 16, 2018, 7:37pm UTC](https://forum.inductiveautomation.com/t/reseting-table-data/17368/10 "2018-03-16T19:37:05Z")

</div>

Also, I don’t think the old version of the module you’ve chosen to use allows the asterisk (column wildcard). You’ll probably have to spell out all of your column names.

---

<div class="post-metadata">

**Author:** ![carolineuchoa.estuda](https://avatars.discourse-cdn.com/v4/letter/c/ba8739/32.png) [@carolineuchoa.estuda](https://forum.inductiveautomation.com/u/carolineuchoa.estuda)\
**Post date:** [March 19, 2018, 4:41pm UTC](https://forum.inductiveautomation.com/t/reseting-table-data/17368/11 "2018-03-19T16:41:37Z")

</div>

Now it’s working, but everything just goes blank, the table is “gone”. What should I do?

---

<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:** [March 19, 2018, 4:56pm UTC](https://forum.inductiveautomation.com/t/reseting-table-data/17368/12 "2018-03-19T16:56:00Z")

</div>

What did you put in the startDate property? No data after that will show up – that’s the whole point. Set it to more than an hour ago and you’ll get your previous data. Set it to “now” (via button script) and the data will disappear, then recent data will appear as time passes.

---

<div class="post-metadata">

**Author:** ![carolineuchoa.estuda](https://avatars.discourse-cdn.com/v4/letter/c/ba8739/32.png) [@carolineuchoa.estuda](https://forum.inductiveautomation.com/u/carolineuchoa.estuda)\
**Post date:** [March 19, 2018, 5:48pm UTC](https://forum.inductiveautomation.com/t/reseting-table-data/17368/14 "2018-03-19T17:48:24Z")

</div>

![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/f/fb119cd0c3474cd20b66a753c2e008fb7f6c931b.png)

---

<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:** [March 19, 2018, 6:37pm UTC](https://forum.inductiveautomation.com/t/reseting-table-data/17368/15 "2018-03-19T18:37:05Z")

</div>

`rawData` needs your Tag History binding as shown in your 3rd comment, and as I already stated in my 2nd and 3rd comments. What was originally bound to data. The view() method will take that dataset and filter it to exclude rows older than `startDate`.

---

<div class="post-metadata">

**Author:** ![abhilashaj2214](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@abhilashaj2214](https://forum.inductiveautomation.com/u/abhilashaj2214)\
**Post date:** [August 6, 2019, 6:47am UTC](https://forum.inductiveautomation.com/t/reseting-table-data/17368/16 "2019-08-06T06:47:25Z")

</div>

hey hi  
can u help me in 1 script . where i have a table in ignition from mysql and adding the rows from ignition from translational list and after adding the rows in table becomes zero.? is this possible

---

<div class="post-metadata">

**Author:** ![abhilashaj2214](https://avatars.discourse-cdn.com/v4/letter/a/a183cd/32.png) [@abhilashaj2214](https://forum.inductiveautomation.com/u/abhilashaj2214)\
**Post date:** [August 6, 2019, 6:53am UTC](https://forum.inductiveautomation.com/t/reseting-table-data/17368/17 "2019-08-06T06:53:30Z")

</div>

i want a help a from u guys.  
actually i hava a table in ignition from mysql DB wwithout any rows and i wanted to add the rows in database from table only. ex im able to add value in table after tapping the add button all data should push it the mysql database after that rows in the ignition table becomes zero.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [August 6, 2019, 11:26am UTC](https://forum.inductiveautomation.com/t/reseting-table-data/17368/18 "2019-08-06T11:26:28Z")

</div>

This should really be in it's own topic.

In the meantime, this should point you in the right direction for moving a dataset into a database:

> [@Insert power table into DB table](http://forum.inductiveautomation.com/t/insert-power-table-into-db-table/18369):
>
> How can you insert a power table dataset into a DB table. My plan is to use an Update query passing in the table headers as the DB columns and the detail rows as VALUES, but I don’t know how to iterate through the table to do this. Is there another way maybe to import the entire dataset at once by turning it into a csv or something?? Thanks

How to clear a dataset:  
[https://docs.inductiveautomation.com/display/DOC80/system.dataset.clearDataset](https://docs.inductiveautomation.com/display/DOC80/system.dataset.clearDataset)
