# How to compare data in different sets of documents matched by their timestamp in Kibana

**URL:** <https://discuss.elastic.co/t/how-to-compare-data-in-different-sets-of-documents-matched-by-their-timestamp-in-kibana/228166>\
**Category:** Kibana\
**Created:** [April 15, 2020, 4:05pm UTC](https://discuss.elastic.co/t/how-to-compare-data-in-different-sets-of-documents-matched-by-their-timestamp-in-kibana/228166 "2020-04-15T16:05:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ris](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ris/32/48935_2.png) [@ris](https://discuss.elastic.co/u/ris)\
**Post date:** [April 15, 2020, 4:05pm UTC](https://discuss.elastic.co/t/how-to-compare-data-in-different-sets-of-documents-matched-by-their-timestamp-in-kibana/228166/1 "2020-04-15T16:05:00Z")

</div>

Hi,

I am new to Kibana and elasticsearch and run into a problem with some basic analysis, where I want to compare different sets of documents matched by their timestamp in Kibana

The situation is as follows:  
We are uploading sensor data from different devices and I want to compare data of deviceA with data of deviceB.

This means data of both devices should be matched based on timestamp for analysis.  
Analysis I would like to do with this data:

- Plot sensordata of deviceA (yaxis) against deviceB (xaxis)
- (average) difference between deviceA and deviceB
- etc

Documents stored contain a device ID, timestamp and sensordata

Is this possible in Kibana? Is there an option to do some custom preprocessing of data in Kibana? Or would I need to add a plugin?

Thank you!

---

<div class="post-metadata">

**Author:** ![Marius\_Dragomir](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marius_dragomir/32/42087_2.png) [@Marius\_Dragomir](https://discuss.elastic.co/u/Marius_Dragomir)\
**Post date:** [April 16, 2020, 12:37pm UTC](https://discuss.elastic.co/t/how-to-compare-data-in-different-sets-of-documents-matched-by-their-timestamp-in-kibana/228166/2 "2020-04-16T12:37:34Z")

</div>

If both devices have timestamps in the same bucket(time interval), there shouldn't be any problem in getting them displayed on the same chart.  
Can you post some examples on how a document looks like so we can get more of an idea?

---

<div class="post-metadata">

**Author:** ![ris](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ris/32/48935_2.png) [@ris](https://discuss.elastic.co/u/ris)\
**Post date:** [April 16, 2020, 7:43pm UTC](https://discuss.elastic.co/t/how-to-compare-data-in-different-sets-of-documents-matched-by-their-timestamp-in-kibana/228166/3 "2020-04-16T19:43:56Z")

</div>

Thanks for your reply! Yes they are at the same time interval.  
This is an example document:

```auto
    {
      ...,
      "_source": {
        "deviceID": {
            "keyword": "deviceA"
        },
        "timestamp": 1586953800000,
        "co2": 448,
        "pm10": 8,
        ...
      }
    }

```

There is no problem displaying them in the same chart with time as x-axis.  
But I want to be able to plot for example co2 of deviceA on the x-axis and co2 of deviceB on the y-axis.  
An example:

 ![example refgraph](https://us1.discourse-cdn.com/elastic/original/3X/3/d/3d85a4153e336838dfd0720977e119914b1058ac.png)  
For other analytics I am running into the same issue: I want to query deviceA and get the corresponding data of deviceB matching the timestamp of deviceA, and then do some comparisons and then display in kibana. I looked into canvas with sql which works nice, but then there are no subqueries suported to do this it seems?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 14, 2020, 7:46pm UTC](https://discuss.elastic.co/t/how-to-compare-data-in-different-sets-of-documents-matched-by-their-timestamp-in-kibana/228166/4 "2020-05-14T19:46:27Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
