question

FrancineN avatar image
0 Likes"
FrancineN asked FrancineN commented

How to sum label values from a list

I am pushing tokens that contain the label "smallItemQty" with a numeric value to a list.

I want to pull from the list 1 token with the sum of the value of all tokens with that, resulting in 1 token labeled "totalSmallItemQty".

I tried "select SUM (token.smallItemQty) AS totalSmallItemQty" as a query but wth no luck.

I also tried adding the values with setting a variable and using statistical collection but I could not get that to work either plus it's not my preferred option since I want to do additional things with the summed value using the token label value.

I did not try a loop yet since I figured a simple SUM query in a pull should do the trick (The pushed values will be coming in at a specific moment and not continuously. ).

FlexSim 23.2.0
listsqlsum
· 2
5 |100000

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

Joerg Vogel avatar image Joerg Vogel commented ·

SELECT SUM(fieldname of list) should do it. Activate on general tab: Assign SELECT Values to Puller Labels.

Try Use First SELECT value as Quantifier

Try also Track Number Field Totals.

From: https://docs.flexsim.com/en/23.1/Reference/Tools/GlobalLists/General/General.html

clauses in a query are typical in upper case characters.

0 Likes 0 ·
FrancineN avatar image FrancineN commented ·

Thanks for your reply. I checked the options suggested but I could not get it to work unfortunately.

Some screenshots, of my list and my pull request. I also attached the model.

The pull result I am aiming to get is "7"


The error I am receiving when it want to pull:

exception: Exception caught in start() of activity Check for full pallet pick/Pull from List in process flow "ProcessFlow". Continuing throw...

exception: Exception caught in Executive::processeventinlist().


Thanks in advance for any help you can offer.


FullPalletPick.fsm


1714683973613.png

1714684126728.png


0 Likes 0 ·
1714683973613.png (4.7 KiB)
1714684126728.png (25.6 KiB)
fullpalletpick.fsm (40.4 KiB)

1 Answer

Joerg Vogel avatar image
1 Like"
Joerg Vogel answered FrancineN commented

I got to run as a table query in a source code:Sum_List_field.fsm


sum-list-field.fsm (30.7 KiB)
· 2
5 |100000

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

Felix Möhlmann avatar image Felix Möhlmann commented ·

Note that this only works for a global list. The only way I've found to get the sum from an internal list is to pull all values with the select clause and then add together the entries of the resulting array.

sum-list-field_1.fsm

0 Likes 0 ·
FrancineN avatar image FrancineN commented ·

Adding together the array values did the trick, thank you both for your help!

0 Likes 0 ·