Is there a readymade function to get the sum of all the values in a particular column of a table? I can do it with for loop but again, lot of coding. Please let me know.
Is there a readymade function to get the sum of all the values in a particular column of a table? I can do it with for loop but again, lot of coding. Please let me know.
You can use the query command and use SQL to find the sum:
query("SELECT SUM([Col 1]) FROM GlobalTable1"); int sum = getqueryvalue(1, 1);
But that's about the same amount of coding as a for loop:
int sum = 0; for(int i = 1; i <= gettablerows("GlobalTable1"); i++) sum += gettablenum("GlobalTable1", i, 1);
@Arun KR Thanks Arun, I already wrote a user command. Just wanted to know whether they have any automatic function.
Thankks Matthew. I thought so. I was hoping for something like
totalsum=columnsum("Tablename",range from column).
getdatastat(STAT_SUM, gettablerows("GlobalTable1"), gettablenum("GlobalTable1", count, 1))
5 People are following this question.
FlexSim can help you understand and improve any system or process. Transform your existing data into accurate predictions.
FlexSim is a fully 3D simulation software environment. FlexSim can be used to simulate any process in any industry.
FlexSim®, FlexSim Healthcare™, Problem Solved.®, the FlexSim logo, the FlexSim X-mark, and the FlexSim Healthcare logo with stylized Caduceus mark are trademarks of FlexSim Software Products, Inc. All rights reserved.
Privacy | Do not sell or share my personal information | Cookie preferences | Report noncompliance | Terms of use | Legal | © Autodesk Inc. All rights reserved