# Left join using two table but the right table not showing any value in result

**URL:** <https://community.influxdata.com/t/left-join-using-two-table-but-the-right-table-not-showing-any-value-in-result/34571>\
**Category:** InfluxDB 2\
**Tags:** influxdb, flux, join\
**Created:** [June 13, 2024, 8:15am UTC](https://community.influxdata.com/t/left-join-using-two-table-but-the-right-table-not-showing-any-value-in-result/34571 "2024-06-13T08:15:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Indra](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/indra/32/15533_2.png) [@Indra](https://community.influxdata.com/u/Indra)\
**Post date:** [June 13, 2024, 8:15am UTC](https://community.influxdata.com/t/left-join-using-two-table-but-the-right-table-not-showing-any-value-in-result/34571/1 "2024-06-13T08:15:41Z")

</div>

Hello,  
I am new to InfluxDB 2.0, I have collected disk used/free data from my linux and i am trying to get estimation of days left for the disk to be full.

i have created this query to get daily growth of my disk and get the max value for the last seven days:

```auto
growth = from(bucket: "virtual_machines")
  |> range(start: -7d)
  |> filter(fn: (r) => r["_measurement"] == "disk")
  |> filter(fn: (r) => r["_field"] == "used")
  |> filter(fn: (r) => r["host"] == "app_v11")
  |> filter(fn: (r) => r["path"] == "/")
  |> aggregateWindow(every: 1d, fn: last, createEmpty: false)
  |> drop(columns: ["_measurement", "_field", "_start", "_stop", "_time", "fstype","mode","device"])
  |> difference()
  |> max()
  |> toFloat()
  |> yield(name: "grow")

```

then next is getting the last saved total/used/free disk using this query:

```auto
data = from(bucket: "virtual_machines")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "disk")
  |> filter(fn: (r) => r["host"] == "app_v11")
  |> filter(fn: (r) => r["path"] == "/")
  |> filter(fn: (r) => r["_field"] == "used" or r["_field"] == "total" or r["_field"] == "free")
  |> last()
  |> toFloat()
  |> pivot(rowKey:["_time"], columnKey: ["_field"], valueColumn: "_value")
  |> drop(columns: ["_measurement", "_field", "_start", "_stop", "_time", "fstype","mode","device"])
  |> group(columns: ["_measurement"], mode:"by")
  |> yield(name:"data")

```

both result seems correct when i checked to my linux server.

but when i tried to use growth value (first table) to left join into data table, the result is empty, the query i use is:

```auto
join.left(
  left: data,
  right: growth,
  on: (l, r) => (l.host == r.host and l.path == r.path),
  as: (l, r) => ({l with growth_value: r._value}),
)
  |> yield(name:"data")

```

result for all three query:

 ![image](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/2X/d/de7b11fd313b424206d3510f7ebe8e4b4ac28e01.png)

please help me for the correct query for this, and what is the query to calculate free and growth\_value measurement to get estimation days left for disk to be full. i think it should be free / growth\_value is good enough to get days left. how to translate this to flux query

Thank you!

---

<div class="post-metadata">

**Author:** ![ebabeshko](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/ebabeshko/32/14844_2.png) [@ebabeshko](https://community.influxdata.com/u/ebabeshko)\
**Post date:** [June 16, 2024, 2:54pm UTC](https://community.influxdata.com/t/left-join-using-two-table-but-the-right-table-not-showing-any-value-in-result/34571/2 "2024-06-16T14:54:00Z")

</div>

You can use [map](https://docs.influxdata.com/flux/v0/stdlib/universe/map/) function to perform calculations in flux:

```auto
import "array"
import "join"

data = array.from(rows:[{free : 51552239616.0, host : "app_v11", label : "ubuntu--vg--ubuntu--lv", path : "/", total : 265080094720.0, used : 202495074304.0}])
yield(tables : data, name : "data")

growth = array.from(rows:[{_value : 333168640.0, host : "app_v11", label : "ubuntu--vg--ubuntu--lv", path : "/"}])
yield(tables : growth, name : "growth")

join.left(
  left: data,
  right: growth,
  on: (l, r) => (l.host == r.host and l.path == r.path),
  as: (l, r) => ({l with growth_value: r._value}),
)
|> map(fn: (r) => ({r with days_left: int( v: r.free / r.growth_value)}))
|> yield(name:"join")

```

 ![зображення](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/2X/1/1906851b788f424ca11381a0cf5c0252de50a655.png)
