# Easy Chart - Save data for excel

**URL:** <https://forum.inductiveautomation.com/t/easy-chart-save-data-for-excel/37543>\
**Category:** Ignition\
**Tags:** ignition79\
**Created:** [August 10, 2020, 12:43pm UTC](https://forum.inductiveautomation.com/t/easy-chart-save-data-for-excel/37543 "2020-08-10T12:43:50Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![conlonj25](https://avatars.discourse-cdn.com/v4/letter/c/258eb7/32.png) [@conlonj25](https://forum.inductiveautomation.com/u/conlonj25)\
**Post date:** [August 10, 2020, 12:43pm UTC](https://forum.inductiveautomation.com/t/easy-chart-save-data-for-excel/37543/1 "2020-08-10T12:43:50Z")

</div>

I have historical data stored in no particular order with tag historian (default historical scan class with default settings, unlimited time between records). Now the customer is requesting all of last years historical data as an excel file with a fixed interval of one minute.

Obviously, my raw data isn’t in the required format so I’m attempting to export it via the easychart “save data for excel” function. It’s doing exactly what I’m looking for except I can’t seem to coerce it into minute intervals. Is this an option?

Any help much appreciated.

---

<div class="post-metadata">

**Author:** ![zacht](https://avatars.discourse-cdn.com/v4/letter/z/ea5d25/32.png) [@zacht](https://forum.inductiveautomation.com/u/zacht)\
**Post date:** [August 10, 2020, 4:12pm UTC](https://forum.inductiveautomation.com/t/easy-chart-save-data-for-excel/37543/2 "2020-08-10T16:12:58Z")

</div>

I don’t know if you can do it with the easy chart, but you could look into [system.tag.queryTagHistory](https://docs.inductiveautomation.com/display/DOC79/system.tag.queryTagHistory) and [system.dataset.exportExcel](https://docs.inductiveautomation.com/display/DOC79/system.dataset.exportExcel).

Specifically, look at the intervalMinutes argument for queryTagHistory.

---

<div class="post-metadata">

**Author:** ![bpreston](https://avatars.discourse-cdn.com/v4/letter/b/4af34b/32.png) [@bpreston](https://forum.inductiveautomation.com/u/bpreston)\
**Post date:** [August 10, 2020, 4:13pm UTC](https://forum.inductiveautomation.com/t/easy-chart-save-data-for-excel/37543/3 "2020-08-10T16:13:08Z")

</div>

Personally for what your doing, if you want 1 minute intervals, I wouldn’t use the easy chart functions, I would create my own, you can use the easy chart to set a range, then give an export button with:

```auto
start = #set your start date
end = #set your end date
rs = system.date.minutesBetween(start,end)
tPaths = ['your tag path']

th = system.tag.queryTagHistory(paths=tPaths,startDate=start,endDate=end,returnSize=rs)

filePath = system.dataset.exportCSV("data.csv",1,th)

```

You still need to set your start and end date to use this, but you can link it to the start/end of your easy chart then put this in the action performed of a button.

---

<div class="post-metadata">

**Author:** ![conlonj25](https://avatars.discourse-cdn.com/v4/letter/c/258eb7/32.png) [@conlonj25](https://forum.inductiveautomation.com/u/conlonj25)\
**Post date:** [August 20, 2020, 9:39am UTC](https://forum.inductiveautomation.com/t/easy-chart-save-data-for-excel/37543/4 "2020-08-20T09:39:57Z")

</div>

Thanks lads, that’s exactly what I’m looking for. I knew there had to be a better way.

---

<div class="post-metadata">

**Author:** ![lportas](https://avatars.discourse-cdn.com/v4/letter/l/e480ec/32.png) [@lportas](https://forum.inductiveautomation.com/u/lportas)\
**Post date:** [June 10, 2021, 8:43pm UTC](https://forum.inductiveautomation.com/t/easy-chart-save-data-for-excel/37543/5 "2021-06-10T20:43:53Z")

</div>

Can you suggest the correct syntax to link the tPaths to the pen list of an Easy Chart? Ive got a dozen or so charts already setup and would like to use your solution for exporting better data, but cant seem to get the tags list working.  
Thanks!

---

<div class="post-metadata">

**Author:** ![bpreston](https://avatars.discourse-cdn.com/v4/letter/b/4af34b/32.png) [@bpreston](https://forum.inductiveautomation.com/u/bpreston)\
**Post date:** [June 10, 2021, 8:58pm UTC](https://forum.inductiveautomation.com/t/easy-chart-save-data-for-excel/37543/6 "2021-06-10T20:58:09Z")

</div>

I can think of two quick examples if you replace:

```auto
tPaths = ['your tag path']

```

with

```auto
pensDS = event.source.parent.getComponent('Easy Chart').tagPens
pensDS = system.dataset.toPyDataSet(pensDS)
tPaths = []
for row in pensDS:
	tPaths.append(row[1])

```

or

```auto
pensDS = event.source.parent.getComponent('Easy Chart').tagPens
tPaths = []
for x in range(pensDS.getRowCount()):
	tPaths.append(pensDS.getValueAt(x,1))

```

This is assuming you are using the tagPens for the easy chart. This is also assuming that your path to the easy chart is the same as what I showed.

---

<div class="post-metadata">

**Author:** ![lportas](https://avatars.discourse-cdn.com/v4/letter/l/e480ec/32.png) [@lportas](https://forum.inductiveautomation.com/u/lportas)\
**Post date:** [June 10, 2021, 8:59pm UTC](https://forum.inductiveautomation.com/t/easy-chart-save-data-for-excel/37543/7 "2021-06-10T20:59:37Z")

</div>

Thanks for the speedy reply. We’ll give it a try.

---

<div class="post-metadata">

**Author:** ![bpreston](https://avatars.discourse-cdn.com/v4/letter/b/4af34b/32.png) [@bpreston](https://forum.inductiveautomation.com/u/bpreston)\
**Post date:** [June 10, 2021, 9:03pm UTC](https://forum.inductiveautomation.com/t/easy-chart-save-data-for-excel/37543/8 "2021-06-10T21:03:00Z")

</div>

No problem, you posted at the perfect time, I was checking the forum hoping the rain would slow down so I could walk to my car.

---

<div class="post-metadata">

**Author:** ![bpreston](https://avatars.discourse-cdn.com/v4/letter/b/4af34b/32.png) [@bpreston](https://forum.inductiveautomation.com/u/bpreston)\
**Post date:** [June 10, 2021, 9:10pm UTC](https://forum.inductiveautomation.com/t/easy-chart-save-data-for-excel/37543/9 "2021-06-10T21:10:55Z")

</div>

One other suggestion that is a little cleaner is:

```auto
pensDS = system.dataset.toPyDataSet(event.source.parent.getComponent('Easy Chart').tagPens)
tPaths = [row[1] for row in pensDS]

```

---

<div class="post-metadata">

**Author:** ![lportas](https://avatars.discourse-cdn.com/v4/letter/l/e480ec/32.png) [@lportas](https://forum.inductiveautomation.com/u/lportas)\
**Post date:** [June 10, 2021, 9:33pm UTC](https://forum.inductiveautomation.com/t/easy-chart-save-data-for-excel/37543/10 "2021-06-10T21:33:03Z")

</div>

I took your first suggestion and ran with it. I had originally tried the nested getComponent / toPyDataSet functions but couldnt quite get it. We’ve already got a chunk of the data exported and off to be polished so thanks again!

---

<div class="post-metadata">

**Author:** ![robertm](https://avatars.discourse-cdn.com/v4/letter/r/ea5d25/32.png) [@robertm](https://forum.inductiveautomation.com/u/robertm)\
**Post date:** [June 23, 2023, 1:09pm UTC](https://forum.inductiveautomation.com/t/easy-chart-save-data-for-excel/37543/11 "2023-06-23T13:09:22Z")

</div>

Older post but relevant to a project im working on. Is there a way to amend the script to only generate tag paths for pens that are enabled?

Edit: I meant if the pen has User Selection enabled, and a user has turned the pen off. Anyway to ignore that pen in the tag path generation?

---

<div class="post-metadata">

**Author:** ![bpreston](https://avatars.discourse-cdn.com/v4/letter/b/4af34b/32.png) [@bpreston](https://forum.inductiveautomation.com/u/bpreston)\
**Post date:** [June 23, 2023, 2:29pm UTC](https://forum.inductiveautomation.com/t/easy-chart-save-data-for-excel/37543/12 "2023-06-23T14:29:55Z")

</div>

Something like this should work:

```auto
pensDS = system.dataset.toPyDataSet(event.source.parent.getComponent('Easy Chart').tagPens)
tPaths = [row[1] for row in pensDS if row[5]]

```

---

<div class="post-metadata">

**Author:** ![robertm](https://avatars.discourse-cdn.com/v4/letter/r/ea5d25/32.png) [@robertm](https://forum.inductiveautomation.com/u/robertm)\
**Post date:** [June 23, 2023, 9:55pm UTC](https://forum.inductiveautomation.com/t/easy-chart-save-data-for-excel/37543/13 "2023-06-23T21:55:59Z")

</div>

Unfortunately no. Thats the property that is indeed if the pen is enabled statically, but it doesnt appear to follow the dynamic user selection of turning a pen off. Neither does row [17] which is the property that allows a pen to be turned off by a user. But i cant seem to find the dynamic value that indicates a pen HAS been turned off.

I realize my question was posed incorrectly. By "enabled" i meant user selected from the pen chart.

The goal is to have an easy chart with 20 pens available, user selectable on or off using the USER SELECT property. Depending on which pens are selected and being trended, i want to export the data only for those pins. Basically using the easy chart to handle the filtering of data as these charts already exist.

---

<div class="post-metadata">

**Author:** ![robertm](https://avatars.discourse-cdn.com/v4/letter/r/ea5d25/32.png) [@robertm](https://forum.inductiveautomation.com/u/robertm)\
**Post date:** [June 27, 2023, 3:02pm UTC](https://forum.inductiveautomation.com/t/easy-chart-save-data-for-excel/37543/14 "2023-06-27T15:02:32Z")

</div>

Okay, I'm an idiot. The ENABLED property does work that bpreston suggested. I didn't realize that the original Easy Chart creator did a 1:1 translation of tag pens to calculated pens (multiply by 1) and that the ENABLED on the pen select dialog was tied to the calculated pens, not the tag pens. Not sure why they did that, as I need to query the tag pens to get the tag paths, so I'll redo the chart to get rid of calculated pens and use tag pens direct since the calculations are all pass through multiply by 1.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [June 28, 2023, 12:08am UTC](https://forum.inductiveautomation.com/t/easy-chart-save-data-for-excel/37543/15 "2023-06-28T00:08:45Z")

</div>

I'll go out on a limb and say you'll probably see an uptick in performance as well.

---

<div class="post-metadata">

**Author:** ![robertm](https://avatars.discourse-cdn.com/v4/letter/r/ea5d25/32.png) [@robertm](https://forum.inductiveautomation.com/u/robertm)\
**Post date:** [June 29, 2023, 9:14pm UTC](https://forum.inductiveautomation.com/t/easy-chart-save-data-for-excel/37543/16 "2023-06-29T21:14:26Z")

</div>

Implemented and working well. A trivial issue and I found some older threads of people asking, but no solutuon....

Is there a way to orgainze pens in a particular order in an easy chart without deleting and recreating? Alohabetical works fine for chart presentation, but for the data dump, the dataset strictly follows the order of the tag pen entry. Surprised that theres not a promote/demote feature to move the rows of the data set around in the configurator.

---

<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:** [June 29, 2023, 11:37pm UTC](https://forum.inductiveautomation.com/t/easy-chart-save-data-for-excel/37543/17 "2023-06-29T23:37:41Z")

</div>

It **is** a dataset property. There are a number of ways to assign a sorted version to the chart. Start with [system.dataset.sort()](https://docs.inductiveautomation.com/display/DOC81/system.dataset.sort) in a script, or use [sortDataset()](https://docs.inductiveautomation.com/display/DOC81/sortDataset) in an expression binding.

Or, if you are scripting pen addition and deletion, do the sort during that operation.

---

<div class="post-metadata">

**Author:** ![robertm](https://avatars.discourse-cdn.com/v4/letter/r/ea5d25/32.png) [@robertm](https://forum.inductiveautomation.com/u/robertm)\
**Post date:** [June 30, 2023, 12:11am UTC](https://forum.inductiveautomation.com/t/easy-chart-save-data-for-excel/37543/18 "2023-06-30T00:11:54Z")

</div>

Interesting....might have to append an "1\_", "2\_" and so on to the row name to define the order i want and do a natural sort. As always, thanks for the direction. Something to play with.
