# 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:** 20\
**Page:** 2

<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 21, 2021, 5:54pm UTC](https://forum.inductiveautomation.com/t/combine-two-datasets/45855/23 "2021-04-21T17:54:25Z")

</div>

sir what i am trying to achieve is , in chart when user selected 2 tags and in chart its showing data from 4 am to 5am for both the tags  
but what i am trying is do offset concept. i want to show second tag from 4.10am to 4.50am some offset to second tag

so i am trying to run **system.tag.queryTagHistory** for every selection of tags in tag tree browser and i am changing start time and end time in query to show some offset between the tags

but i want to show all the tags data in single dataset. because timestamp column will be same

can you help me on this

---

<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:** [April 21, 2021, 6:00pm UTC](https://forum.inductiveautomation.com/t/combine-two-datasets/45855/24 "2021-04-21T18:00:51Z")

</div>

If you are running a separate query for each one, then you can append each query result to a list, then sent that list to the function

```python
datasetList = []
for tag in tagList:
	datasetList.append(system.tag.queryTagHistory(tag, other_params, as_needed)

combinedData = combineDatasets(datasetList)

```

---

<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 21, 2021, 6:17pm UTC](https://forum.inductiveautomation.com/t/combine-two-datasets/45855/25 "2021-04-21T18:17:09Z")

</div>

> [@JordanCClark](#):
>
> ```python
> if event.propertyName = 'selectedPaths':
> selectedPaths = event.source.selectedPaths
> tagList = []
> for i in selectedPaths.rowCount:
> tagList.append = selectedPaths.getValueAt(i,0)
> 
> ```

'int' object is not iterable still same error **for i in selectedPaths.rowCount:** - in this line

---

<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:** [April 21, 2021, 6:29pm UTC](https://forum.inductiveautomation.com/t/combine-two-datasets/45855/26 "2021-04-21T18:29:47Z")

</div>

Sorry, my caffeine must have run out. Time for more coffee…

```auto
for i in range(selectedPaths.rowCount):

```

---

<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 21, 2021, 6:35pm UTC](https://forum.inductiveautomation.com/t/combine-two-datasets/45855/27 "2021-04-21T18:35:43Z")

</div>

> [@JordanCClark](#):
>
> `for i in range(selectedPaths.rowCount):`

no problem sir

readonly attribute - getting this error

---

<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:** [April 21, 2021, 6:49pm UTC](https://forum.inductiveautomation.com/t/combine-two-datasets/45855/28 "2021-04-21T18:49:57Z")

</div>

Better show us what you have so far, and the full error text. The error isn’t making any sense to me at the moment.

---

<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 21, 2021, 6:54pm UTC](https://forum.inductiveautomation.com/t/combine-two-datasets/45855/29 "2021-04-21T18:54:27Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/c/2c7c01d10733ba2018db730e4a3e7c5bdc1f4c3f.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/7/a7983410db1655b9c55b82aacc98fe001c5457d8.png)

error and script i have attached

---

<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:** [April 21, 2021, 6:59pm UTC](https://forum.inductiveautomation.com/t/combine-two-datasets/45855/30 "2021-04-21T18:59:22Z")

</div>

Wow, I really dropped the ball on that one.

```python
if event.propertyName = 'selectedPaths':
	selectedPaths = event.source.selectedPaths
	tagList = []
	for i in selectedPaths.rowCount:
		tagList.append(selectedPaths.getValueAt(i,0))

```

Updated my post above.

---

<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, 4:43am UTC](https://forum.inductiveautomation.com/t/combine-two-datasets/45855/31 "2021-04-23T04:43:58Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/8/c8e17901c1a57724141b6b19a99f48cca31391a6.png)  
 ![normal chart](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/f/1f00c582a6b4570934eeb41bdcc105d13668ab45.png)

i used this script merge to dataset values.

but i am getting output like this.

is there any way to correct the issue?

---

<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, 6:07am UTC](https://forum.inductiveautomation.com/t/combine-two-datasets/45855/32 "2021-04-23T06:07:54Z")

</div>

what is the issue exactly?  
i notice you 2nd colum says kWh **Ton** while the other one is just kwh, might be better to visualise if they both have the same unit

---

<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, 6:30am UTC](https://forum.inductiveautomation.com/t/combine-two-datasets/45855/33 "2021-04-23T06:30:10Z")

</div>

both are different tags, i merging 2 different tags dataset in to single dataset. keeping timestamp column common for both. when i merge i am getting output like that.

---

<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, 6:30am UTC](https://forum.inductiveautomation.com/t/combine-two-datasets/45855/34 "2021-04-23T06:30:54Z")

</div>

this is what i am trying to do

sir what i am trying to achieve is , in chart when user selected 2 tags and in chart its showing data from 4 am to 5am for both the tags  
but what i am trying is do offset concept. i want to show second tag from 4.10am to 4.50am some offset to second tag

so i am trying to run **system.tag.queryTagHistory** for every selection of tags in tag tree browser and i am changing start time and end time in query to show some offset between the tags

but i want to show all the tags data in single dataset. because timestamp column will be same

---

<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, 6:34am UTC](https://forum.inductiveautomation.com/t/combine-two-datasets/45855/35 "2021-04-23T06:34:53Z")

</div>

im not sure if its smart to offset data on a chart, that is very confusing to know the actual values then.  
Is a different color not enough?  
Right now the Ton vlaue table just appears as a flat line becuase the values are only 10 while the other table goes to 16000  
I suggest you multiply the second collum by a 1000 aswell and call it kwh.

---

<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, 6:36am UTC](https://forum.inductiveautomation.com/t/combine-two-datasets/45855/36 "2021-04-23T06:36:17Z")

</div>

but i have assigned task to do that. so only i am trying hard to find solution

---

<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, 6:37am UTC](https://forum.inductiveautomation.com/t/combine-two-datasets/45855/37 "2021-04-23T06:37:26Z")

</div>

then i guess you multiply by 999 or something. I suggest you do taht in a new dataset so you keep the actualy values unchanged  
Its very weird tho. Also what are these numbers? such high values for kwh every second? xD

---

<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, 6:38am UTC](https://forum.inductiveautomation.com/t/combine-two-datasets/45855/38 "2021-04-23T06:38:39Z")

</div>

Ya tired with other tags also. but same issue, some space is showing in chart

---

<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, 6:40am UTC](https://forum.inductiveautomation.com/t/combine-two-datasets/45855/39 "2021-04-23T06:40:33Z")

</div>

What is the result if you multiple second clm by 1000?

---

<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, 6:42am UTC](https://forum.inductiveautomation.com/t/combine-two-datasets/45855/40 "2021-04-23T06:42:24Z")

</div>

no i don’t want to multiple. because its actual tag value i want to show in chart  
i am getting the output by running **system.tag.queryTagHistory**

---

<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, 6:47am UTC](https://forum.inductiveautomation.com/t/combine-two-datasets/45855/41 "2021-04-23T06:47:19Z")

</div>

Yes but one colum has a different unit than the other so you cant show them on the same chart than unless you convert it to match.  
i mean you can but then you just get what you ahve now

---

<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, 6:50am UTC](https://forum.inductiveautomation.com/t/combine-two-datasets/45855/42 "2021-04-23T06:50:07Z")

</div>

ya ok please let me know if you any other idea to do offset concept . which i mentioned above. in your free time please think about it

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

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