# Combine two datasets

**URL:** <https://forum.inductiveautomation.com/t/combine-two-datasets/45855>\
**Category:** Ignition\
**Created:** [April 21, 2021, 10:24am UTC](https://forum.inductiveautomation.com/t/combine-two-datasets/45855 "2021-04-21T10:24:03Z")\
**Posts on this page:** 12\
**Page:** 4

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [April 23, 2021, 7:56am UTC](https://forum.inductiveautomation.com/t/combine-two-datasets/45855/63 "2021-04-23T07:56:30Z")

</div>

> [@Ignition Chart - Connect Lines Between Missing Data](http://forum.inductiveautomation.com/t/ignition-chart-connect-lines-between-missing-data/18420/2):
>
> My experience with Ignition is to brute force various combinations of Properties to get the behavior that you want. That doesn’t look like an Easy Chart, maybe try Easy Chart vs Chart?. But maybe you can turn on Interpolation? With the Easy Chart there are a few parameters Under “Tag History” heading that you can experiment with

Looks like you will have to use 2 datasets afterall in the chart. You can still keep the combined one to show in a table tho

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [April 23, 2021, 11:43am UTC](https://forum.inductiveautomation.com/t/combine-two-datasets/45855/65 "2021-04-23T11:43:34Z")

</div>

actually what they are doing is splitting single dataset in to 2 separate datasets

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [April 23, 2021, 12:04pm UTC](https://forum.inductiveautomation.com/t/combine-two-datasets/45855/66 "2021-04-23T12:04:37Z")

</div>

yes, but you dont need to split it since you already have the 2 datasets from before.  
you just need to add both datasets to the chart instead of the one combined chart

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [April 23, 2021, 12:21pm UTC](https://forum.inductiveautomation.com/t/combine-two-datasets/45855/67 "2021-04-23T12:21:26Z")

</div>

ya correct but user will choose more than 2 .so only planning to give in single dataset

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [April 23, 2021, 1:26pm UTC](https://forum.inductiveautomation.com/t/combine-two-datasets/45855/68 "2021-04-23T13:26:44Z")

</div>

Null values will always leave a “gap”.  
You can try to fill up the Null values yourself with some values and lots of math, but that will be quite complex

There also isn’t a way to add datasets to the chart through scripting. (i think) But you can try to add the max number of datasets you will ever likely need ( 10?). You can enable/disable ones that you don’t want to use like this:`chart = event.source.parent.getComponent('Chart') chart.setDatasetEnabled("Data", 1)` You can set it to a 0 or 1.  
And then fill up and activate the ones with those that are selected.

Im afraid there isnt an easy option (that i know off)

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [April 23, 2021, 1:52pm UTC](https://forum.inductiveautomation.com/t/combine-two-datasets/45855/69 "2021-04-23T13:52:38Z")

</div>

Ya OK I will give it a try and check

---

<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:** [April 24, 2021, 10:47am UTC](https://forum.inductiveautomation.com/t/combine-two-datasets/45855/70 "2021-04-24T10:47:02Z")

</div>

You will have to post-process one dataset to _ **lie** _ about its time to get them to overlay. Ignition’s charts **cannot** apply a time shift.

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [May 9, 2021, 9:59am UTC](https://forum.inductiveautomation.com/t/combine-two-datasets/45855/73 "2021-05-09T09:59:10Z")

</div>

```auto
tag = event.source.parent.getComponent('Tag Browse Tree').selectedPaths
current_data = event.source.parent.getComponent('Chart').Data
print current_data

offset = 5
endTime = system.date.now()
endTime = system.date.addMinutes(endTime, -15)
startTime = system.date.addMinutes(endTime, -300)
print startTime, endTime

dataSet = system.tag.queryTagHistory(paths=[str(tag.getValueAt(0, 0))], startDate=startTime, endDate=endTime, returnSize=current_data.getRowCount(), aggregationMode="Average", returnFormat='Wide')
print dataSet

columnName = str(tag.getValueAt(0, 0))
colCount = current_data.getColumnCount()
columnData = []

for i in range(dataSet.getRowCount()):
	columnData.append(dataSet.getValueAt(i,1))
	
dataSet = system.dataset.addColumn(current_data, colCount, columnData, columnName, float)
event.source.parent.getComponent('Chart').Data = dataSet

```

error i am getting

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/9/b9a7647c7e7ed962ade10edf0880ee1998e4e535.png)

i am trying add column to dataset

by using

system.tag.queryTagHistory(paths=[str(tag.getValueAt(0, 0))], startDate=startTime, endDate=endTime, **returnSize=current\_data.getRowCount(),** aggregationMode=“Average”, returnFormat=‘Wide’)

see the return size i am getting the dataset row count. if query runs it has return the same amount of rows in dataset  
but its not returning the same row count

what i did wrong in this?

---

<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:** [May 9, 2021, 12:15pm UTC](https://forum.inductiveautomation.com/t/combine-two-datasets/45855/74 "2021-05-09T12:15:36Z")

</div>

That error means you have a different number of rows in `current_data` versus `dataSet`. You’ll have to adjust the length of `columnData` to match before you can add the column.

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [May 9, 2021, 2:09pm UTC](https://forum.inductiveautomation.com/t/combine-two-datasets/45855/75 "2021-05-09T14:09:22Z")

</div>

Yes I given the current dataset row count to query to return the same number for rows  
Still row count not matching  
**returnSize=current\_data.getRowCount()**

---

<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:** [May 10, 2021, 11:26am UTC](https://forum.inductiveautomation.com/t/combine-two-datasets/45855/76 "2021-05-10T11:26:48Z")

</div>

What happens if you use **returnSize = current\_data.getRowCount() + 1**, being as you’re one short one the returned dataset?

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [May 10, 2021, 11:40am UTC](https://forum.inductiveautomation.com/t/combine-two-datasets/45855/77 "2021-05-10T11:40:19Z")

</div>

yes, issue is when i select tag from different folder and run the query row count issue happening

when i select within UDT Folder no issue. i found the issue.

this will be also good option **returnSize = current\_data.getRowCount() + 1** thanks

[Previous page](https://forum.inductiveautomation.com/t/combine-two-datasets/45855.md?page=3)
