2.4 KiB
2.4 KiB
title | description | aliases | menu | weight | flux/v0.x/tags | related | introduced | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
toBool() function | The `toBool()` function converts all values in the `_value` column to booleans. |
|
|
102 |
|
|
0.7.0 |
The toBool()
function converts all values in the _value
column to booleans.
toBool()
{{% note %}}
To convert values in a column other than _value
, define a custom function
patterned after the function definition,
but replace _value
with your desired column.
{{% /note %}}
Supported data types
- string:
true
orfalse
- int:
1
or0
- uint:
1
or0
- float:
1.0
or0.0
Parameters
tables
Input data.
Default is piped-forward data (<-
).
Examples
{{% flux/sample-example-intro %}}
Convert an integer value column to a boolean column
import "sampledata"
sampledata.numericBool()
|> toBool()
{{< expand-wrapper >}} {{% expand "View input and output" %}} {{< flex >}} {{% flex-content %}}
Input data
{{% flux/sample "numericBool" %}}
{{% /flex-content %}} {{% flex-content %}}
Output data
_time | tag | _value |
---|---|---|
2021-01-01T00:00:00Z | t1 | true |
2021-01-01T00:00:10Z | t1 | true |
2021-01-01T00:00:20Z | t1 | false |
2021-01-01T00:00:30Z | t1 | true |
2021-01-01T00:00:40Z | t1 | false |
2021-01-01T00:00:50Z | t1 | false |
_time | tag | _value |
---|---|---|
2021-01-01T00:00:00Z | t2 | false |
2021-01-01T00:00:10Z | t2 | true |
2021-01-01T00:00:20Z | t2 | false |
2021-01-01T00:00:30Z | t2 | true |
2021-01-01T00:00:40Z | t2 | true |
2021-01-01T00:00:50Z | t2 | false |
{{% /flex-content %}} | ||
{{< /flex >}} | ||
{{% /expand %}} | ||
{{< /expand-wrapper >}} |