# Sum Based on Unique Values

**URL:** <https://community.glideapps.com/t/sum-based-on-unique-values/69532>\
**Category:** Ask for Help\
**Created:** [January 13, 2024, 3:10pm UTC](https://community.glideapps.com/t/sum-based-on-unique-values/69532 "2024-01-13T15:10:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cmelvin84](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/cmelvin84/32/64136_2.png) [@Cmelvin84](https://community.glideapps.com/u/Cmelvin84)\
**Post date:** [January 13, 2024, 3:10pm UTC](https://community.glideapps.com/t/sum-based-on-unique-values/69532/1 "2024-01-13T15:10:21Z")

</div>

Hi All, Newbie Here!

Im attempting to create an app where I have a table of Meal Names, Ingredients and Quantity of said ingredients per meal.

The aim is that the user selects a meal (or multiple) and the required ingredients are then shown.

I have managed this part however i now am struggling where rather than ingredients being repeated in a list id like a single occurrence of the ingredient with a sum of the total requirements of said ingredient.

Below is a table where you can see the ingredients, “New column” identifies where its parent meal has been selected but you will see multiple “onion” for example.

How can i generate a unique list yet sum the total requirements?

thanks

Chris

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/d/d/dd84af70947fedd8828c08a17749ae5bcfca9c1e.png)

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [January 13, 2024, 10:42pm UTC](https://community.glideapps.com/t/sum-based-on-unique-values/69532/2 "2024-01-13T22:42:10Z")

</div>

- Add a rowID column to the Ingredients table.
- Create a query on that same Ingredients table, filter by ingredient is the same as this row \> ingredient and “new column A” (please name this column accordingly) is checked.
- Add a rollup column to sum the quantity on top of the query.
- Add a single value column to return the first rowID from the query.
- Show a collection targetting this table, filter by rowID is the same as the single value column, and quantity \> 0.

---

<div class="post-metadata">

**Author:** ![Cmelvin84](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/cmelvin84/32/64136_2.png) [@Cmelvin84](https://community.glideapps.com/u/Cmelvin84)\
**Post date:** [January 15, 2024, 8:59am UTC](https://community.glideapps.com/t/sum-based-on-unique-values/69532/4 "2024-01-15T08:59:58Z")

</div>

Hi ThinDinh,

So after multiple false starts i finally did what you suggested properly and it works splendidly, my sincere thanks!

Whilst undoubtedly powerful getting my head around this not being a spreadsheet is taking some time 🙂

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/system/32/53398_2.png) [@system](https://community.glideapps.com/u/system)\
**Post date:** [January 22, 2024, 9:00am UTC](https://community.glideapps.com/t/sum-based-on-unique-values/69532/5 "2024-01-22T09:00:45Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
