# How to get total of rows based on a column value?

**URL:** https://community.glideapps.com/t/how-to-get-total-of-rows-based-on-a-column-value/23643
**Category:** Ask for Help
**Created:** [March 2, 2021, 8:53am UTC](https://community.glideapps.com/t/how-to-get-total-of-rows-based-on-a-column-value/23643 "2021-03-02T08:53:34Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![vijay](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/vijay/32/3259_2.png) [@vijay](https://community.glideapps.com/u/vijay)
#### Post date: [March 2, 2021, 8:53am UTC](https://community.glideapps.com/t/how-to-get-total-of-rows-based-on-a-column-value/23643/1 "2021-03-02T08:53:34Z")

</div>

I have rows with date as one column and sales as another column. I use rollup to get the total of sales column. But, how do I separate the rows based on date and get the total of sales column values only for one date? For example, there are ten rows with one date value in date column, and I want total of all sales values in the ten rows. How do I use rollup in this case?

---

<div class="post-metadata">

### Author: ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)
#### Post date: [March 2, 2021, 9:04am UTC](https://community.glideapps.com/t/how-to-get-total-of-rows-based-on-a-column-value/23643/2 "2021-03-02T09:04:33Z")

</div>

- Create a template column to “lock” the value of your date. This will contain just a single replacement, which is the date.
- Use that column to create a multi-relation, joining the column to itself (ie. a self-relation)
- Create a rollup column, calculating the sum of amounts through that relation

---

<div class="post-metadata">

### Author: ![vijay](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/vijay/32/3259_2.png) [@vijay](https://community.glideapps.com/u/vijay)
#### Post date: [March 2, 2021, 9:19am UTC](https://community.glideapps.com/t/how-to-get-total-of-rows-based-on-a-column-value/23643/3 "2021-03-02T09:19:35Z")

</div>

Thanks! That is an awesome idea! I have implemented it. Now I am thinking of how to display it. I want to display the date and sales in each date. Right now, I have two values A and B for two dates X and Y. For each date X, there is A in the column, and for Y there is B in the column. How to show Date X - A and Date Y - B?

---

<div class="post-metadata">

### Author: ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)
#### Post date: [March 7, 2021, 12:51am UTC](https://community.glideapps.com/t/how-to-get-total-of-rows-based-on-a-column-value/23643/4 "2021-03-07T00:51:00Z")

</div>

Can you explain a little more or share screenshots of what you have now? Are you saying that your 10 rows only have 2 dates, or they could have any number of dates and you want a get a single cell that lists each unique Date-Sales as a string of text?

---

<div class="post-metadata">

### Author: ![vijay](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/vijay/32/3259_2.png) [@vijay](https://community.glideapps.com/u/vijay)
#### Post date: [March 7, 2021, 2:47am UTC](https://community.glideapps.com/t/how-to-get-total-of-rows-based-on-a-column-value/23643/5 "2021-03-07T02:47:21Z")

</div>

Yes, thats right. It may have any number of dates, and I want to get a single cell that lists each unique Date- Sales as a string of text.

---

<div class="post-metadata">

### Author: ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)
#### Post date: [March 7, 2021, 5:09am UTC](https://community.glideapps.com/t/how-to-get-total-of-rows-based-on-a-column-value/23643/6 "2021-03-07T05:09:21Z")

</div>

First, if you don’t already have a Row ID column, I would add one. Create a Template column joining date and the rollup of sales. Since you already have that self relation, I would add a single value column that gets the first row id from the relation. Then create an If Then column to compare the Row ID column to the Single Value column. If it matches, then return the date/sales template. Else return nothing. Finally create a Joined List column that will join all the values in the If Then column. The final result should be a joined list of unique dates and total sales for each date.

---

<div class="post-metadata">

### Author: ![22c304](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/22c304/32/19733_2.png) [@22c304](https://community.glideapps.com/u/22c304)
#### Post date: [March 7, 2021, 4:13pm UTC](https://community.glideapps.com/t/how-to-get-total-of-rows-based-on-a-column-value/23643/7 "2021-03-07T16:13:31Z")

</div>

I am having trouble implementing this.  
I want to sum the Line Total by Unique ID. That is I want a sum for all of the line totals that have the same unique id.  
I have a Unique ID for each line that comes from A Work Orders file, this work fine.  
I have a Relation set up on Unique ID that is multi (see pic).  
I have a rollup column that sums line total but is bringing back all the line totals, not just the one (see pic).What am i doing wrong. Many thanks …  
 ![Line Total Rollup](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/a/b/ab0215a4aa7d994136b42deb2c361aa89879e08a.png)

 ![UID Multi](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/7/d/7de3a57dff5f3693689adc476be5a7c55151eae4.png) ![UID](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/0/a/0a77a50aafc1a482d57f99c0c80cc16585531565.png)

---

<div class="post-metadata">

### Author: ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)
#### Post date: [March 7, 2021, 4:19pm UTC](https://community.glideapps.com/t/how-to-get-total-of-rows-based-on-a-column-value/23643/8 "2021-03-07T16:19:36Z")

</div>

Your rollup column is pointing to the sheet, so it sums everything in the sheet. You need to point it to the relation so it only sums the data with the same unique id.

---

<div class="post-metadata">

### Author: ![22c304](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/22c304/32/19733_2.png) [@22c304](https://community.glideapps.com/u/22c304)
#### Post date: [March 7, 2021, 4:33pm UTC](https://community.glideapps.com/t/how-to-get-total-of-rows-based-on-a-column-value/23643/9 "2021-03-07T16:33:48Z")

</div>

WOWZER …  
Thank you kind sir.

---

<div class="post-metadata">

### Author: ![NoCodeAndy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/nocodeandy/32/62530_2.png) [@NoCodeAndy](https://community.glideapps.com/u/NoCodeAndy)
#### Post date: [January 17, 2024, 4:53pm UTC](https://community.glideapps.com/t/how-to-get-total-of-rows-based-on-a-column-value/23643/11 "2024-01-17T16:53:01Z")

</div>


