I have this object. SORT_BY_KEY doesnt seem to arrange the numbers in order. Is there anything I’m missing? I’m trying to quantity_sold by the key quantity_key.
Your formula should most likely be like: SORT_BY_KEY(GROUP(data.SalesRecordsAll, item.name, {name_key: key , name: items.name, quantity_key: key, quantity: items.quantity_sold }), "quantity" )
What is the “name_key” and “quantity_key”? Why do you need them?
When you group your items with the GROUP() formula, you get the “item.name” as the “key”, so in your case it would be like this:
I am really not sure what is your business logic behind it, but one thing I know… Referring to items[0] will always find you the first item in the grouped list. Which in most cases is not the solution people are trying to achieve.
Hey thanks for your reply. I’ll try your suggession.
Here’s the background. So I have a collection of sales with products (which I’m calling name) being sold and appear as a list in the collection so some appear more than once if sold many times. The formula there groups the collection as name (product). This is the GROUP formula.
Now to get the total quantity for each grouped name using the SUM function. To make sure it sums only each name seperately I’m using the repeat formula.
This should be the way to go then. Just try this formula and let me know if it helps. You basically don’t have to do any modifications to it. Just copy-paste.
This contains your MAP() formula in itself. There is no need to do that, as the GROUP() formula is powerful enough to give you the option to sum up the count of items that are grouped under a single name.