Skip to main content
1-Visitor
August 29, 2019
Solved

How to retrieve data from aggregate function which from services in datatable.

  • August 29, 2019
  • 1 reply
  • 3672 views

May I know how to put value which is from aggregate function in data table services, and what is the output? 

 

Best answer by PaiChung

// result: INFOTABLE dataShape: "RootEntityList"
var tempTable = ThingTemplates["GenericThing"].GetImplementingThings();
var params = {
t: tempTable /* INFOTABLE */,
columns: "name" /* STRING */,
aggregates: "COUNT" /* STRING */,
groupByColumns: undefined /* STRING */
};

// result: INFOTABLE
var result = Resources["InfoTableFunctions"].Aggregate(params);

 

be sure to set the service output to InfoTable

1 reply

22-Sapphire I
August 29, 2019

I'm not sure if I'm answering the right question, but it sounds like you want to know how to use the Aggregate function provided in the infotable services?

Aggregate needs an infotable

second you specify which columns you want to operate on for example "col1,col2,col1,col3" note no spaces!

third you specify what aggregate you want to do per those columns "SUM,AVERAGE,MAX,MIN"

(last one would be COUNT)

You can specify columns by which it will do groupings

 

The output then will be an infotable that will feature SUM_col1, AVERAGE_col2, MAX_col1, MIN_col3 and your grouping columns if specified.

 

Hope that is what your quest is asking.

 

xiaoqw1-VisitorAuthor
1-Visitor
August 29, 2019

Thank you for ur reply. I think the logistic is correct. Could u show me the specific code like an example to go through it?

PaiChung22-Sapphire IAnswer
22-Sapphire I
September 4, 2019

// result: INFOTABLE dataShape: "RootEntityList"
var tempTable = ThingTemplates["GenericThing"].GetImplementingThings();
var params = {
t: tempTable /* INFOTABLE */,
columns: "name" /* STRING */,
aggregates: "COUNT" /* STRING */,
groupByColumns: undefined /* STRING */
};

// result: INFOTABLE
var result = Resources["InfoTableFunctions"].Aggregate(params);

 

be sure to set the service output to InfoTable