# How to interpolate data source using flux?

I have the following source table:

``````Table1
time  | sensor
2     | 1.0
5     | 2.0
7     | 4.0
``````

and secondary source

``````Table2
time  | temperature
1     | 20.0
10    | 30.0
``````

Times are in nanosecond precision which I would like to retain.
What I would like to have in resulting table is exactly same time series as in Table1 and additionally interpolated values of temperature from Table2.

``````Table Result
time  | data | temperature
2     | 1.0  | x
5     | 2.0  | x
7     | 4.0  | x
``````

I’ve checked `interpolate.linear`, which unfortunately using fixed intervals. Also checked `fill` function, which doesn’t interpolate.

How to join two tables with interpolation?

Hello @Georgy,
Welcome! Thank you for your question.
Here ya go:

``````import "join"
import "interpolate"
import "array"

one = array.from(rows: [{_time: 2020-01-02, _value: 1.0}, {_time: 2020-01-05, _value: 2.0}, {_time: 2020-01-07, _value: 4.0}])
// |> yield(name: "one")

two = array.from(rows: [{_time: 2020-01-01, _value: 20.0}, {_time: 2020-01-10, _value: 30.0}])
|> interpolate.linear(every: 1d)
//  |> yield(name: "two_interpolated")

join.left(
left: one,
right: two,
on: (l, r) => l._time == r._time,
as: (l, r) => ({_time: l._time, v_left: l._value, v_right: r._value}),
)
|> yield(name: "desired output")
``````

@Anaisdg Thanks!

It means interpolate must divide series into sufficient granularity, so every point in from series “one” will find corresponding point in interpolated series. What will happen if there will be no matching point?
The actual data contains irregular timestamps in nanosecond resolution and it’s not clear what interval to specify interpolation. The smaller interval I specify, I guess the slower computations will go, but in any case there is no guarantee that matching point will be always found (if I understand solution correctly).