How to extract scalar values using InfluxDB 1.8 (without findColumn() or find Record())

Hello, I’m wondering if there is a way to extract scalar values using InfluxDB 1.8? I am trying to find a mean of a column, and then use that value in a map function. To do this I need to store the mean value as a float, but the only way I’ve seen to do that is with findColumn() or findRecord() which are only for InfluxDB 2.0.
This is a representation of my current code:

import "math"

getInitialMean = (bucket, start, stop, measure, path, direction) => {
    mean = from(bucket: bucket)
    |> range(start:start, stop: stop)
    |> filter(fn: (r) => r._measurement == measure)
    |> filter(fn: (r) => r.path == path)
    |> filter(fn: (r) => r.pos == direction)
    |> mean()
    |> toFloat()
    |> yield(name: "${direction} mean")

    return float(v: mean._value)}


x = getInitialMeans(...)
y = getInitialMeans(...)


getDistance = (tables=<-, xAvg=x, yAvg=y) => {
  xTable = 
    tables
    |> filter(fn: (r) => r.pos == "X")
    |> map(fn: (r) => ({ r with
      x_squared:
        math.pow(x:r._value - xAvg, y:2.0)
        })
        )
      
  yTable = 
    tables
    |> filter(fn: (r) => r.pos == "Y")
        |> map(fn: (r) => ({ r with
      y_squared:
        math.pow(x:r._value - yAvg, y:2.0)
      })
    )

  combined = 
    join(tables: {xTable:xTable, yTable:yTable}, on: ["_time"])
    |> map(fn: (r) => ({ r with
      dist:
        math.sqrt(x: r.x_squared + r.y_squared)
      })
    )
  return combined
  }

I am getting this error code- 500 Internal Server Error: {"error":"compile function @ 25:16-28:11: type error 27:9-27:43: float != nil"} This is refering to this line "math.pow(x:r._value - xAvg, y:2.0)" and it is saying that xAvg is nil.

@annariley In InfluxDB 1.8, you need to use tableFind() |> getColumn() or tableFind() |> getRecord() (these are the predecessors to findColumn() and findRecord()). These are covered in the 1.8 documentation: Extract scalar values in Flux | InfluxDB OSS 1.8 Documentation