Graphing median from United MultiStream Shifted Data

Hi to the Community!

As a new at Flux lang I have some quandaries with queries.
Now I have 2 streams to make them united and in seems like this:


data1 = from(bucket: v.bucket)
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["host"] == "monitoring")
  |> filter(fn: (r) => r["_field"] == "usage_user")
  |> filter(fn: (r) => r["cpu"] == "cpu-total")
  
   |> yield(name: "now")

data2 = from(bucket: v.bucket)
  |> range(start: -1h15m, stop: -1h)
  |> filter(fn: (r) => r["host"] == "monitoring")
  |> filter(fn: (r) => r["_field"] == "usage_user")
  |> filter(fn: (r) => r["cpu"] == "cpu-total")
  |> timeShift(duration: 1h) 
  |>  yield(name: "old")

  union(tables: [data1, data2] )

Unfortunately, I have a strange line instead of something I had expected:

Ideally, I’m looking for a way to combine two (maybe more) different periods and make a graph from the figures taken by a function like median(), mean(), etc.

I’d appreciate any help to point me to a mistake I made or function I missed.
Influxdb 2.7

Hello @Azimuth,
You might want to order by time with the sort() function after union.
I don’t know if time order is preserved which might be causing the weird line.
Does that help?