Wrong result in JS client and influx cloud query

Hi,

I am using influx cloud and this query returns inconsistent results when run on influx cloud and when run using the JS/ node library.

Why is that?

import “math”
import “strings”

data_1 = from(bucket: “returns”)
|> range(start: 1609439400, stop: 1614448943)
|> filter(fn: ® => r["_measurement"] == “returns-daily”)
|> filter(fn: ® => r["_field"] == “supervised_return_gof_pre_tax” or r["_field"] == “supervised_return_gof_post_tax”)
|> filter(fn: ® => r[“account_number”] == “939888955”)
|> map(fn: ® => ({
_value: r._value + 1.00000 ,
_time: r._time,
_field: r._field
}))
|> reduce(fn: (r, accumulator) => ({
pre_tax: if r._field == “supervised_return_gof_pre_tax” then r._value * accumulator.pre_tax else accumulator.pre_tax ,
post_tax: if r._field == “supervised_return_gof_post_tax” then r._value * accumulator.post_tax else accumulator.post_tax,
}),
identity: {pre_tax: -1.0, post_tax: -1.0})
|> drop(columns: ["_field", “_measurement”])
|> reduce(fn: (r, accumulator) => ({
pre_tax: math.abs(x: r.pre_tax * accumulator.pre_tax) ,
post_tax: math.abs(x: r.post_tax * accumulator.post_tax),
tax_alpha: (r.post_tax * accumulator.post_tax) - (r.pre_tax * accumulator.pre_tax)
}),
identity: {pre_tax: 1.0, post_tax: 1.0, tax_alpha: 0.0})
|> yield()

Hi @Rahul_Vyas1 , can you give us an example of what the different results look like?

Influx Cloud -

post_tax - 1.051587798286076
pre_tax - 1.0517962245854924
tax_alpha - 0.00020842629941641988

Influx Node/JS client -

{
result: ‘_result’,
table: 0,
post_tax: 69797773.09837243,
pre_tax: 11112471.726996416,
tax_alpha: -58685301.371376015
}

@mhall119
The output from the influx cloud data explorer is correct. How can i resolve this?

Thanks in advance
Rahul