Hello. In Flux, is there a way to limit the number of decimal places in a value?
For example, if a value is 1.35147851, I would like to convert it to 1.35
1 Like
Because math.round() will only return the nearest Intger you need to multiply it first.
Like:
yourValue = math.round(x: ((1.35147851) * 100.0)) / 100.0
or with map()
|> map(
fn: (r) =>
({r with
_value: (math.round(x: r._value * 100.0) / 100.0),
}),
)
1 Like
the result is 1.350000. It works for what I want, but I think there should be a function that gives 1.35
That is kinda wierd. Maybe you missed a bracket? Because math.round will give you an Integer an if you calculate (1.35147851) * 100.0 and round it, it is 135 and that divided by 100 should give 1.35. Or maybe your schema adds all the zeroes?
Thanks for this. Too bad it took me 30 minutes to realize it couldn’t be on a single line… for some reason!