Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X
I am trying to use aggregate function on a "result" infotable. The aggregate function is returning and info table "result1". The infotable result1 column names are
infoTable content: {AVERAGE_1667.0=null, AVERAGE_1667.0_COUNT=com.thingworx.types.primitives.NumberPrimitive@0, AVERAGE_1667.0_SUM=com.thingworx.types.primitives.NumberPrimitive@0}
Please find my code below. How do I read the read the aggregated value(i.e Average values: 1667 this keeps changing every time I run this service)
// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(US_NRV_Env_Reporting_Average_Value)
var result1 = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params1);
var params = {
t: result /* INFOTABLE */,
columns: me.Data_Reading/* STRING */,
aggregates: "AVERAGE" /* STRING */,
groupByColumns: undefined /* STRING */
};
// result: INFOTABLE
result1 = Resources["InfoTableFunctions"].Aggregate(params);
further you need to iterate result1 infotable using infotable for loop to get the aggregate value
for loop is present in snippets tab of service(under infotable functions)