Skip to main content
1-Visitor
January 31, 2020
Question

Aggregate function on Infotable

  • January 31, 2020
  • 1 reply
  • 2149 views

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);

 

 

 

1 reply

16-Pearl
February 4, 2020

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)