Skip to main content
May 19, 2025 12:51 AM UTC
Solved

How to Average an Infotable Value

I have an output from my SQL database saved as an InfoTable in ThingWorx (I've already filtered the timestamp before extracting it). How can I average all of the data in my InfoTable? I couldn't find a way to extract the data into an array (if that's even possible).

RockoAnswer
May 19, 2025 6:40 AM UTC

You could try something like this:

var params = { t: myInfoTable, columns: "Quantity, Age", aggregates: "AVERAGE"};
var result = Resources["InfoTableFunctions"].Aggregate(params);

 

You might also want to check https://community.ptc.com/t5/IoT-Connectivity-Tips/Getting-to-Know-InfoTables-pdf/ta-p/818843

 

 

 

3 replies

RockoAnswer
May 19, 2025 6:40 AM UTC

You could try something like this:

var params = { t: myInfoTable, columns: "Quantity, Age", aggregates: "AVERAGE"};
var result = Resources["InfoTableFunctions"].Aggregate(params);

 

You might also want to check https://community.ptc.com/t5/IoT-Connectivity-Tips/Getting-to-Know-InfoTables-pdf/ta-p/818843

 

 

 

Jun 9, 2025 6:43 AM UTC

Hi @AF_01_10333884 ,

It appears that there is a reply that answers your question.  For the benefit of other Community Members who may have the same question, it would be great if you could designate it as the Accepted Solution.

In the event that this response did not answer your question, please post your current status so that we can continue to support.

Thanks for using the PTC Community!

Regards,


Charles

May 22, 2025 11:34 AM UTC

Just a thought: Could you let the database produce an average for you?

dgg