Formulas used for transforming Device Studio poller results in NPM
formula | description |
---|---|
KiloToByte |
Multiplies input by 1024 |
MegaToByte | Multiplies input by 1024 x 1024 |
GigaToByte |
Multiplies input by 1024 x 1024 x 1024 |
Average | Returns the average of values from the input columns |
Sum |
Returns the sum of values from the input columns |
Count | Returns the total number of input columns |
Condition | Creates an if/then statement |
Truncate | Rounds the input decimal number up or down to an integer |
Length | Returns the number of characters in the input string |
Replace | Replaces the content in the string |
IndexOf | Returns the position in the string |
SubString | Defines the section of the string of interest |
The formulas are divided into three main groups.
type of formula | description |
---|---|
Transformations | Transform data between different units. For example, transform megabytes to bytes. |
Aggregations | Transform the values from the input table columns to scalar values. For example, transform the values from the input columns into the average of values. |
Conditions | Transform values according to a logical formula according to the following syntax: if(logical formula), (action to perform if formula is true), (action to perform if formula is false) |
Example syntax
SubString
The SubString(,,) calculation takes the following syntax:SubString ([formula],index start,length)
For example, if your input is "test", the output will be "es" if you use the following calculation:SubString ([UsedMemoryFormula],1,2)
As another example, if your input is "test", the output will be "st" if you use the following calculation:SubString ([UsedMemoryFormula1],2,2)
Replace
The Replace(,,) calculation takes the following syntax:Replace([formula],search string,replacement string)
For example, if your input is "test", the output will be "resr" if you use the following calculation: Replace([UsedMemoryFormula1],"t","r")
Use Regex formulas for transforming poller results
When you define a Regex formula, use the following syntax:Regex([variable],"regular expression")
Examples of correct formulas include:
- Regex([description],"^([a-zA-Z]*[^,])*")
- Regex([description],"(V.[^,]*)")
- Regex([description],"(T.*)")
- Regex([description],"(C.[^ ]+)")
Limitations of Regex formulas
When you define a Regex formula, the input string from the test device is interpreted up until the nearest \r (new line) character.
The following methods of defining Regex formulas are not supported:
- A backslash sequence for special characters such as the following:
(,),{,},
. - Grouping regular functions such as the following:
\w, \W, \s, \S
. - Defining multiple conditions in square brackets such as the following:
[^ ,-]
.