Make Numeric aggregator: sum quantities by category
Compare raw and cleaned category labels. Then sum up the quantity from a single grouped array. Also get a total count of rows.

Use Make Numeric aggregator to summarize imaginary order quantities per category. It's done in Make Free, without any external app integrations.
Before you start
For a one off table? Better to use a spreadsheet. Use this step if the totals should be in a repeated Make workflow. You'll need to have a make account to do this tutorial. You can either get started with Make Free (opens in a new tab) or log into your Make account. (Be aware of the current plan limits (opens in a new tab) before you start working on a more complicated scenario).
1. Create three practice records
Click on Create scenario, enter Category quantity totals as the name, then insert JSON > Parse JSON. Set Data structure as blank. In the JSON string, copy and paste the given JSON array.
Click on Save, and then Run once. If you get an unused-output warning, Run anyway (this is practice!). Look up in the output bubble, right above JSON.
[
{"category":"Stationery","quantity":2},
{"category":"stationery ","quantity":3},
{"category":"Packaging","quantity":4}
]
The JSON array up above returns three output bundles. Each bundle is a record. There is a trailing space in the second category value. Keep this in mind when comparing grouping values (raw vs cleaned). Use Enlarge image followed by Open full-size image to see smaller controls in the screenshot.
2. Sum quantities by category
- add (by click the plus next to JSON) Tools > Numeric aggregator
- Source Module = JSON - Parse JSON [1] Aggregate function = SUM
- Click Value - pick the purple quantity element from JSON mapping panel
- Enable Show advanced settings In Group by pick JSON's category element.
- Click Save then Run once and Run anyway (if asked)
- Open the bubble above Tools
With the raw labels we get three different sums
- The exact key (capital S at beginning) Stationery = 2
- The different key (all small with a space inside the key's ending)
stationery= 3 - The key Packaging = 4
The original tags just divided your stationery into 2 and 3 totals.
Watch out
Group by will be based on the value of the category after evaluation. Different capitalisations or edge spaces may cause one category to be split into separate sums. So only "clean" the grouping value if you want these to be ignored. Now, lets combine the two stationery entries.
3. Clean the grouping value
- Open the Numeric aggregator. Grab all in Group by. Paste the following expression. Assume that JSON is module 1.
{{lower(trim(1.category))}}
trim strips both leading spaces AND trailing spaces off category text. lower will make all category text lower case. Group by use these functions on category. The separate Value field is mapped to quantity as before. Stop processing after empty aggregation is left unchecked for this practice.
The settings add by SUM of quantity. The Group by is set as lower(trim(1.category)).
- After pressing Save - press Run once. If you get unused output warning, select Run anyway.
- Check result bubble of Tools. Two bundles of outputs should be shown: Key: stationery, result: 5. Key: packaging, result: 4.
The cleaned-up grouping of the labels gives us two bundles of output: stationery with result 5 and packaging with result 4.
4. Save the practice scenario
- Use Save on bottom tool bar. If Make gives you a warning that final output is not used, then select Save anyway.
- Scenario remains Inactive. This will stop at result inspector and does not send anything out.
Note that these totals are for the records passed in for this run. These totals are not summed up between different runs. In a larger flow you will need to know which records are in the aggregator. Pass the aggregator's Key and result to the next module.
If the totals look wrong
If you are not getting quantiy or category in the mapping panel, try JSON by itself first. If you have a formula that is referencing the wrong module number, sub 1 with your JSON module number. If they are still seperate, try and make sure they are spelled right. Neither trim or lower will fix spelling errors. Check your numeric quanities for accuracy before you trust the totals.
If you also need a row count
Don't change Numeric aggregator practice. Add one more scenario. Let's call it Grouped totals and row count practice. It should give both quantity sum and input row count from the same grouped array. If quantity is 0 - this is still 1 input row.
- Now add JSON > Parse JSON. Paste initial 3 records. Invoke it once. Add Flow Control > Array aggregator. Use Source Module as JSON. Target structure type should remain Custom. Choose quantity in Aggregated fields. Click Show advanced settings. Write {{lower(trim(1.category))}} into Group by. Save module.
- Put in Tools > Set variables. Create a variable category. Assign as value the Key token from aggregator. Add 2 variables below.
For quantity_total set:
{{sum(map(2.array; "quantity"))}}
For row_count, simply do:
{{length(2.array)}}
Formulas will assume that your Array aggregator is module 2. If it's a different number, use that module's Array[] token in each of the formulas. Check the docs: map and length (opens in a new tab) & sum (opens in a new tab).
- Save the module and scenario. Run once. Check both Tools ops. See stationery: quantity_total 5 row_count 2 and packaging: quantity_total 4 row_count 1.
- Switch JSON input to 1 record (below) then save & run. Now it should just be packaging: quantity_total 0, row_count 1. Switch back to 3 records input. Save & run again. Should see both groups back. Schedule Inactive.
[{"category":"Packaging","quantity":0}]
row_count counts input row within that group (including a zero quantity row). This is not the count of units or orders (unique).
row_count and other values are based on input records in this run.
For category totals (fictive records) start with Make Free (opens in a new tab) and see the group label before and after cleaning. Inspect both output bundles. Don't forget to turn off the scenario.
Sources: Make Academy: Numeric aggregators (opens in a new tab); aggregation scope and Group by (opens in a new tab); trim and lower (opens in a new tab). Screenshots show the fictional practice scenario.
Share this post
From holdmytwist.com/blog/make-numeric-aggregator-category-totals/


