cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

Aggregate function on Infotable

sk36
3-Visitor

Aggregate function on Infotable

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 1
rosharma
16-Pearl
(To:sk36)

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)

Top Tags