bool() function
bool()
converts a value to a boolean type.
Function type signature
(v: A) => bool
Parameters
v
(Required) Value to convert.
Examples
- Convert strings to booleans
- Convert numeric values to booleans
- Convert all values in a column to booleans
Convert strings to booleans
bool(v: "true")
// Returns true
bool(v: "false")// Returns false
Convert numeric values to booleans
bool(v: 1.0)
// Returns true
bool(v: 0.0)
// Returns false
bool(v: 1)
// Returns true
bool(v: 0)
// Returns false
bool(v: uint(v: 1))
// Returns true
bool(v: uint(v: 0))// Returns false
Convert all values in a column to booleans
If converting the _value
column to boolean types, use toBool()
.
If converting columns other than _value
, use map()
to iterate over each
row and bool()
to convert a column value to a boolean type.
data
|> map(fn: (r) => ({r with powerOn: bool(v: r.powerOn)}))
Was this page helpful?
Thank you for your feedback!
Support and feedback
Thank you for being part of our community! We welcome and encourage your feedback and bug reports for Flux and this documentation. To find support, use the following resources:
Customers with an annual or support contract can contact InfluxData Support.