# Obtain plot difference in chart

**URL:** <https://forum.inductiveautomation.com/t/obtain-plot-difference-in-chart/9069>\
**Category:** Ignition\
**Created:** [September 17, 2014, 8:57am UTC](https://forum.inductiveautomation.com/t/obtain-plot-difference-in-chart/9069 "2014-09-17T08:57:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lauravsp](https://avatars.discourse-cdn.com/v4/letter/l/e47774/32.png) [@lauravsp](https://forum.inductiveautomation.com/u/lauravsp)\
**Post date:** [September 17, 2014, 8:57am UTC](https://forum.inductiveautomation.com/t/obtain-plot-difference-in-chart/9069/1 "2014-09-17T08:57:31Z")

</div>

I am plotting two datasets in a chart and both Datasets have different amount of data.

I want to obtain the difference between both lines, ¿Is there any way to do so?

I can’t go row by row obtaining the difference because the datasets have different lengths.

Thank you,

Laura

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/6/6c364a08144f44ecd9bb6555c0e6e278209d5fde.PNG)

---

<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:** [September 17, 2014, 3:25pm UTC](https://forum.inductiveautomation.com/t/obtain-plot-difference-in-chart/9069/2 "2014-09-17T15:25:36Z")

</div>

Even if they have different number of rows, just loop through the dataset that has less rows.  
You can have the script run when either dataset1 or dataset2 changes.

Maybe even bind the difference dataset to the sql query.

SELECT ID, ABS(val1-val2)  
FROM table

or

SELECT t1.ID, ABS(t1.val1 - t2.val2)  
FROM table1 t1  
JOIN table2 t2 ON t2.ID = t1.ID

---

<div class="post-metadata">

**Author:** ![lauravsp](https://avatars.discourse-cdn.com/v4/letter/l/e47774/32.png) [@lauravsp](https://forum.inductiveautomation.com/u/lauravsp)\
**Post date:** [September 18, 2014, 6:36am UTC](https://forum.inductiveautomation.com/t/obtain-plot-difference-in-chart/9069/3 "2014-09-18T06:36:48Z")

</div>

Yes I could do so, the thing is thay maybe row number 2 from plot 1 corresponds to row number 5 from plot 2…

I woul like to know if I can create a dataset from the plot that gets the Y value every 0,1 X value or something like that.

---

<div class="post-metadata">

**Author:** ![sandhyaochre](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@sandhyaochre](https://forum.inductiveautomation.com/u/sandhyaochre)\
**Post date:** [September 18, 2014, 1:16pm UTC](https://forum.inductiveautomation.com/t/obtain-plot-difference-in-chart/9069/4 "2014-09-18T13:16:00Z")

</div>

Click on the lines.
