Merge pull request #368 from influxdata/flux/difference-keep-first

Added keepFirst parameter to difference function
pull/372/head
Scott Anderson 2019-08-05 13:13:05 -06:00 committed by GitHub
commit 485bd86ff0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 26 additions and 1 deletions

View File

@ -17,7 +17,11 @@ _**Function type:** Aggregate_
_**Output data type:** Float_
```js
difference(nonNegative: false, column: "_value")
difference(
nonNegative: false,
column: "_value",
keepFirst: false
)
```
## Parameters
@ -34,6 +38,13 @@ Defaults to `"_value"`.
_**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
- The difference between two non-null values is their algebraic difference;
or `null`, if the result is negative and `nonNegative: true`;
@ -90,6 +101,20 @@ from(bucket: "example-bucket")
| 0004 | 6 | 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"/>
##### Related InfluxQL functions and statements: