Forum Academy Marketplace Showcase Pricing Features

Group list of data by a certain field

Hey so in my example, I’ve got clients who make multiple purchases (one client can make just one purchase or many purchases. each purchase is one transaction. so client A might have 5 purchases, client B might have 3, and client C only has 1)

Each purchase has an associated dollar amount

I’m using a repeating group to calculate and display the list of each transaction with the associated client. so like this:
client A - $1
client A - $2
client A - $3
client A - $4
client A - $5
client B - $1
client B - $2
client B - $3
client C - $5

I want to create a summarized list of this. so it’d reflect:
client A - $15
client B - $6
client C - $5

what’s the simplest way to achieve this?

Hi there, @luisdavila612… add the :group by operator to the end of the repeating group’s data source. Then, group by the client name and create an aggregation to do a sum of the purchase amount field.

Hope this helps.

Best…
Mike

3 Likes

@mikeloc’s solution is great! I’m throwing one more in for options.

Setup

  1. Add a field to client called “transactionSum” (or something similar).
    Make it type number.

  2. Anytime a new transaction is created: make change to client → transactionSum = transactionSum + newTransactionValue

Then display transactionSum in the summarized list.

This works well for large datasets when you want to display summaries from a large dataset. But for small datasets, it could be over-engineering.

Both are solid solutions!

@mikeloc’s for smaller datasets
@Dillon_Schade’s for larger datasets

I’m reworking a system that worked similarly to @mikeloc’s right now because the dataset was getting too large and was maxing out my capacity.

Screen Shot 2023-01-25 at 21.05.15
Screen Shot 2023-01-25 at 21.05.33
(think of Submits = transactions)
I’m doing this to get a list of each client who submitted transactions

I have this set up but whenever I run it, I get an empty list. Compared to when I do “:unique elements” which returns a list of clients

Unless I am missing something, you shouldn’t need to do all of those merges. Just do a search for submits grouped by client, and add an aggregation for the sum.

the merge is necessary bc not all submits qualify (there’s some special business logic).

so the good part is that I was able to get the list of clients to show.

the bad and weird part, is that the aggregation sum isn’t displayed but I can see that it’s being calculated in the debugger.


Screen Shot 2023-01-25 at 21.33.18
(Estimate Value_Submit Input is the field I use to calculate the $$$ amount)
this is my group by:

any idea of what i might be doing wrong here?