# Get the last value from a different measurement on a specific point of time

**URL:** https://community.influxdata.com/t/get-the-last-value-from-a-different-measurement-on-a-specific-point-of-time/19438
**Category:** InfluxDB 2
**Tags:** influxdb, query, flux
**Created:** [April 16, 2021, 6:57am UTC](https://community.influxdata.com/t/get-the-last-value-from-a-different-measurement-on-a-specific-point-of-time/19438 "2021-04-16T06:57:00Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![strittmm](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/strittmm/32/7159_2.png) [@strittmm](https://community.influxdata.com/u/strittmm)
#### Post date: [April 16, 2021, 6:57am UTC](https://community.influxdata.com/t/get-the-last-value-from-a-different-measurement-on-a-specific-point-of-time/19438/1 "2021-04-16T06:57:00Z")

</div>

Hello there, I am working on a problem where I have many measurements that only consist of a timestamp and store either “on” or “off” (1/0). Lets say I have the measurements FAULT and MONITORING. Is there a way to always get the last value/change form MONITORING when I query FAULT? How would I solve this problem? Does Flux has a way to build that into my query?

---

<div class="post-metadata">

### Author: ![Anaisdg](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/anaisdg/32/6401_2.png) [@Anaisdg](https://community.influxdata.com/u/Anaisdg)
#### Post date: [April 20, 2021, 6:23pm UTC](https://community.influxdata.com/t/get-the-last-value-from-a-different-measurement-on-a-specific-point-of-time/19438/2 "2021-04-20T18:23:35Z")

</div>

Hello @strittmm,  
I’m sorry. I’m confused. How do you expect to query values for measurement FAULT by querying a different measurement, MONITORING. Can you describe what you want in a little bit more detail? Maybe with some example data?  
Thank you

---

<div class="post-metadata">

### Author: ![strittmm](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/strittmm/32/7159_2.png) [@strittmm](https://community.influxdata.com/u/strittmm)
#### Post date: [April 20, 2021, 7:12pm UTC](https://community.influxdata.com/t/get-the-last-value-from-a-different-measurement-on-a-specific-point-of-time/19438/3 "2021-04-20T19:12:30Z")

</div>

Hello @Anaisdg, thanks for responding,

So I am trying to query data for the measurement FAULT. Now I would like to find a way how to get the last value of MONITORING for each timestamp of FAULT. Let’s say I query FAULT and get timestamps for FAULT at `11:15:00`, `11:18:00` and `11:21:00`. Is there a way how to figure out what the last value of MONITORING was at `11:15:00`, `11:18:00` and `11:21:00` even though the timestamps for MONITORING may be `11:14:30`, `11:16:00`, `11:20:45` or something like that. Almost like taking a snapshot of every other value at a timestamp while querying FAULT.

---

<div class="post-metadata">

### Author: ![Anaisdg](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/anaisdg/32/6401_2.png) [@Anaisdg](https://community.influxdata.com/u/Anaisdg)
#### Post date: [April 20, 2021, 7:48pm UTC](https://community.influxdata.com/t/get-the-last-value-from-a-different-measurement-on-a-specific-point-of-time/19438/4 "2021-04-20T19:48:06Z")

</div>

Hello @strittmm,  
Are you using 1.x or 2x? If you’re using 2x you can apply a window function and then join the measurements and gather the last value.

---

<div class="post-metadata">

### Author: ![strittmm](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/strittmm/32/7159_2.png) [@strittmm](https://community.influxdata.com/u/strittmm)
#### Post date: [April 20, 2021, 8:01pm UTC](https://community.influxdata.com/t/get-the-last-value-from-a-different-measurement-on-a-specific-point-of-time/19438/5 "2021-04-20T20:01:31Z")

</div>

I am using 1.8.4 but flux enabled. I am querying data with flux. How would I have to use the window function? Which time window do I need if sometimes the MONITORING changes only milliseconds before FAULT.
