Defaults are overridden by explicitly defining the parameter in the function call.
Parameters without default values are considered required parameters.
Calculate n to the p power (with default parameters)
pow=(n,p=10)=>n^ppow(n:2)// Returns 1024
Create a custom transformation
A transformation is a function that
takes a stream of tables
as input, operates on the input, and then outputs a new stream of tables.
The pipe-forward operator (|>)
pipes data from the previous identifier or function forward into a transformation.
To use piped-forward data, assign a function parameter to the
pipe-receive operator (<-).
In the following example, the function x() receives piped-forwarded data and assigns it to the t parameter.
In the function body, t is piped forward into other operations to generate output.
x=(t=<-)=>t|>//...
Custom transformation examples
Multiply values by x
Multiply values by x
The following example defines a multByX function that multiplies the _value column
of each input row by the x parameter.
The example uses the map() function to iterate over
each row, modify the _value, and then return the updated row.
The following example defines a speed function that calculates speed using an
elapsed and distance column in input tables.
The example uses the map() function to iterate over
each row, calculate the speed per specified unit of distance, and then return
the updated row with a new speed column.
The following function converts a hexadecimal (HEX) color code to the equivalent HTML color name.
The functions uses the Flux dictionary package
to create a dictionary of HEX codes and their corresponding names.
import"dict"hexName=(hex)=>{hexNames=dict.fromList(pairs:[{key:"#00ffff",value:"Aqua"},{key:"#000000",value:"Black"},{key:"#0000ff",value:"Blue"},{key:"#ff00ff",value:"Fuchsia"},{key:"#808080",value:"Gray"},{key:"#008000",value:"Green"},{key:"#00ff00",value:"Lime"},{key:"#800000",value:"Maroon"},{key:"#000080",value:"Navy"},{key:"#808000",value:"Olive"},{key:"#800080",value:"Purple"},{key:"#ff0000",value:"Red"},{key:"#c0c0c0",value:"Silver"},{key:"#008080",value:"Teal"},{key:"#ffffff",value:"White"},{key:"#ffff00",value:"Yellow"},],)name=dict.get(dict:hexNames,key:hex,default:"No known name")returnname}hexName(hex:"#000000")// Returns "Black"
hexName(hex:"#8b8b8b")// Returns "No known name"
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:
Select your InfluxDB Cloud region and cluster or your InfluxDB OSS URL and we’ll customize code examples for you. Identify your InfluxDB Cloud cluster.
InfluxDB v3 enhancements and InfluxDB Clustered is now generally available
New capabilities, including faster query performance and management
tooling advance the InfluxDB v3 product line.
InfluxDB Clustered is now generally available.
InfluxDB v3 performance and features
The InfluxDB v3 product line has seen significant enhancements in query
performance and has made new management tooling available. These enhancements
include an operational dashboard to monitor the health of your InfluxDB cluster,
single sign-on (SSO) support in InfluxDB Cloud Dedicated, and new management
APIs for tokens and databases.