question

Francesco V2 avatar image
0 Likes"
Francesco V2 asked Francesco V2 commented

How to find a average value in one column of a table?

Hello, I have a table.I would like to find an average value of one common in the table. I mean that i would like to do the sum of all values of the column divided by the numbers of rows of the table.

FlexSim 19.2.3
average value in one column
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

·
Joerg Vogel avatar image
1 Like"
Joerg Vogel answered Francesco V2 commented

I would use a Table.query with AVG accumulating clause of the column name

double myColAvg = Table.query(“SELECT AVG(myColName) FROM myTableName”)[1][1];
· 5
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Francesco V2 avatar image Francesco V2 commented ·

Thank you @Jörg Vogel.I have tryed to use the code that you have posted but I don't know if I use it correctly.

I would like to print the result in a specif column and row of the table but I'm not sure how to do it.

I have tryed in this way:

double myColAvg = Table.query(SELECT AVG(cantidad) FROM ListadoOF_Lectura)[1][1];
Table("ListadoOF_Lectura")[1][9] = myColAvg;
0 Likes 0 ·
Joerg Vogel avatar image Joerg Vogel Francesco V2 commented ·

@Francesco V2, you assign correctly the value into a cell row 1 column 9. Is there a problem, that you can’t get the average of column cantidad?

0 Likes 0 ·
Francesco V2 avatar image Francesco V2 Joerg Vogel commented ·

Yes, in the table don't appear the result, I don't know the reason, in the column I have only inter numbers.

0 Likes 0 ·
Show more comments
Francesco V2 avatar image Francesco V2 commented ·

Good morning,@Jörg Vogel, thank you for your file and suggestion, you made my day better.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.