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

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?

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

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.

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.

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.