Sum coding or formula suggestion

I created a popup where it shows store item available to buy / pick. I put the items in a repeating group and I’m able to add the amount with the number of items selected. Now I would like to get a tally of the order outside the repeating group under Sum group so I can show the customer how much is his/her order.
Is there a way that I can add the total of the order at the top of the popup under Sum group?


Should I need to create another data type to hold the selected items or can I have this info without one .
Axel

If I understand correctly, then yes. Number fields of a Thing, when listed in a RG, should have a sum operator available…

Shot,
Yes, I was able to add the code to action however, I think my problem is that I’m not able to hold/save the total value of each item (row) to add all the columns… I’m thinking to create a state and then call the sum of this state. Let me know if you have any additional suggestions,
Axel

Check out the group by and aggregate operators. Here’s a somewhat related example.

If you’re trying to calculate the sum total of the invoice then this can be a bit tricky without RG plugins. Fortunately though there is a way to do it. Here is a workaround solution that uses a workflow on button click to run the total calculation.

1 Like

Yeah, I see what you mean. An iterative approach can come in handy here.

Personally, I don’t care for the UX though - i.e. the seeing the text field update, although I realize that could probably be eliminated by decreasing the update interval. (Plus, there’s a logic error somewhere, since clicking the button a second time doubles the total.)

Alternatively, a calculated Line Total field could be added to the Transaction data type. It would simply be updated whenever a transaction is created or modified, thereby making it completely trivial to get the grand total and eliminating the need for a plugin or iterative workflow. Additionally, it would make it easier and more performant to extract other meaningful metrics should they be needed.

Yeah, I wasn’t solving for UX but rather looking to provide a workable solution to a scenario that kept popping up. I threw that together for someone else who was stuck a while ago.

Yes, just knowing how to iterate over a RG can be useful in other situations as well. :+1: