Merge pull request #368 from influxdata/flux/difference-keep-first
Added keepFirst parameter to difference functionpull/372/head
commit
485bd86ff0
|
@ -17,7 +17,11 @@ _**Function type:** Aggregate_
|
||||||
_**Output data type:** Float_
|
_**Output data type:** Float_
|
||||||
|
|
||||||
```js
|
```js
|
||||||
difference(nonNegative: false, column: "_value")
|
difference(
|
||||||
|
nonNegative: false,
|
||||||
|
column: "_value",
|
||||||
|
keepFirst: false
|
||||||
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
## Parameters
|
## Parameters
|
||||||
|
@ -34,6 +38,13 @@ Defaults to `"_value"`.
|
||||||
|
|
||||||
_**Data type:** String_
|
_**Data type:** String_
|
||||||
|
|
||||||
|
### keepFirst
|
||||||
|
Indicates the first row should be kept.
|
||||||
|
If `true`, the difference will be `null`.
|
||||||
|
Defaults to `false`.
|
||||||
|
|
||||||
|
_**Data type:** Boolean_
|
||||||
|
|
||||||
## Subtraction rules for numeric types
|
## Subtraction rules for numeric types
|
||||||
- The difference between two non-null values is their algebraic difference;
|
- The difference between two non-null values is their algebraic difference;
|
||||||
or `null`, if the result is negative and `nonNegative: true`;
|
or `null`, if the result is negative and `nonNegative: true`;
|
||||||
|
@ -90,6 +101,20 @@ from(bucket: "example-bucket")
|
||||||
| 0004 | 6 | tv |
|
| 0004 | 6 | tv |
|
||||||
| 0005 | null | tv |
|
| 0005 | null | tv |
|
||||||
|
|
||||||
|
|
||||||
|
#### With keepFirst set to true
|
||||||
|
```js
|
||||||
|
|> difference(nonNegative: false, keepfirst: true):
|
||||||
|
```
|
||||||
|
###### Output table
|
||||||
|
| _time | _value | tag |
|
||||||
|
|:-----:|:------:|:---:|
|
||||||
|
| 0001 | null | tv |
|
||||||
|
| 0002 | null | tv |
|
||||||
|
| 0003 | -2 | tv |
|
||||||
|
| 0004 | 6 | tv |
|
||||||
|
| 0005 | null | tv |
|
||||||
|
|
||||||
<hr style="margin-top:4rem"/>
|
<hr style="margin-top:4rem"/>
|
||||||
|
|
||||||
##### Related InfluxQL functions and statements:
|
##### Related InfluxQL functions and statements:
|
||||||
|
|
Loading…
Reference in New Issue