Calculate average value between multiple column in stream
Hi
Let's say I have a stream with this Shape
| Timestamp | Temperature_1 | Temperature_2 | Temperature_3 | Temperature_4 | Temperature_5 | Temperature_6 | Some other stuff... |
|---|---|---|---|---|---|---|---|
And I would like this output
| Timestamp | Average | Minimum | Maximum |
|---|---|---|---|
| Average value between Temperature_1...Temperature_6 | Minimum value between Temperature_1...Temperature_6 | Maximum value between Temperature_1...Temperature_6 |
Is there any snippets which does this without do any loop?
Rightnow I am using DeriveFields but I don't think it's the proper way because what I have to do is
var expr = '';
expr += '(Temperature_1+Temperature_2+Temperature_3+Temperature_4+Temperature_5+Temperature_6)/6,';
var params = {
types: 'NUMBER, NUMBER, NUMBER',
t: stream,
columns: 'Average,Minimum,Maximum'
expressions: expr
};
var outputTable = Resources["InfoTableFunctions"].DeriveFields(params);
outputTable.RemoveField(<name of the field I want to remove>);
outputTable.RemoveField(<name of the field I want to remove>);
outputTable.RemoveField(<name of the field I want to remove>);
outputTable.RemoveField(<name of the field I want to remove>);
...
result = outputTable
but this has two problems:
1) DeriveFields I think is unproperly used because it's supposed to be used when the two infotables have the same fields, here they only have one in common then I have to remove all the other extra fields;
2) To calculate max e minimum temperature I use the function Math.max(Temperature_1, ..., Temperature_6) but expression parameter doesn't want expressions with comma inside so this won't work.
Do you have any better suggestion?

