# Group by in table element

**URL:** <https://forum.bubble.io/t/group-by-in-table-element/295744>\
**Category:** Need help\
**Created:** [December 1, 2023, 12:42pm UTC](https://forum.bubble.io/t/group-by-in-table-element/295744 "2023-12-01T12:42:02Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![riverogonzalez.isaac](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/riverogonzalez.isaac/32/174136_2.png) [@riverogonzalez.isaac](https://forum.bubble.io/u/riverogonzalez.isaac)\
**Post date:** [December 1, 2023, 12:42pm UTC](https://forum.bubble.io/t/group-by-in-table-element/295744/1 "2023-12-01T12:42:02Z")

</div>

Hi there!

I am having issues with the table element. I have energy consumption data by month in my database. However I need the table to display the data by quarter. I have tried to use the group by function but it does not seem to work.

Is there a way to make the table show me the sum of every 3 month?

Thanks!

---

<div class="post-metadata">

**Author:** ![fuhclifffuhche](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/fuhclifffuhche/32/102338_2.png) [@fuhclifffuhche](https://forum.bubble.io/u/fuhclifffuhche)\
**Post date:** [December 1, 2023, 1:37pm UTC](https://forum.bubble.io/t/group-by-in-table-element/295744/2 "2023-12-01T13:37:03Z")

</div>

Have you tried the group by on a repeating group?

Group by functionality is a bit complex, which expression in the group by functionality are you using?

---

<div class="post-metadata">

**Author:** ![georgecollier](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/georgecollier/32/182327_2.png) [@georgecollier](https://forum.bubble.io/u/georgecollier)\
**Post date:** [December 1, 2023, 1:45pm UTC](https://forum.bubble.io/t/group-by-in-table-element/295744/3 "2023-12-01T13:45:04Z")

</div>

> [@riverogonzalez.isaac](#):
>
> Is there a way to make the table show me the sum of every 3 month?

Your new table data source should be (Your current data source):grouped by month (3 month intervals). Add an aggregation that is field’s sum.

---

<div class="post-metadata">

**Author:** ![riverogonzalez.isaac](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/riverogonzalez.isaac/32/174136_2.png) [@riverogonzalez.isaac](https://forum.bubble.io/u/riverogonzalez.isaac)\
**Post date:** [December 1, 2023, 2:07pm UTC](https://forum.bubble.io/t/group-by-in-table-element/295744/4 "2023-12-01T14:07:49Z")

</div>

Thank you very much @fuhclifffuhche @georgecollier,

I have tried pretty much everything but the problem is that I need all the columns to be grouped by at the same time since there are several items in the table (from the same database). However, when I change the data source, Bubble says that I cannot have the current data type (the database) but a data type number, which at the same time basically bugs the whole table.

 ![Capture d’écran 2023-12-01 à 15.02.43](https://us1.discourse-cdn.com/bubble/original/3X/a/4/a401dee7ae28cd747d9ec93ac05ab234c358357a.png)  
 ![Capture d’écran 2023-12-01 à 15.00.37](https://us1.discourse-cdn.com/bubble/original/3X/2/4/24dabdf63b859fea4286db5ae6df18a6db615c5c.png)  
 ![Capture d’écran 2023-12-01 à 14.56.43](https://us1.discourse-cdn.com/bubble/original/3X/f/f/ff8ed2a1a9e97fd199b8a91540cb68ed61e42ad6.png)

---

<div class="post-metadata">

**Author:** ![riverogonzalez.isaac](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/riverogonzalez.isaac/32/174136_2.png) [@riverogonzalez.isaac](https://forum.bubble.io/u/riverogonzalez.isaac)\
**Post date:** [December 1, 2023, 2:23pm UTC](https://forum.bubble.io/t/group-by-in-table-element/295744/5 "2023-12-01T14:23:05Z")

</div>

This is the result I have when I do the group by. What I actually need is to group by every 3 rows…

 ![Capture d’écran 2023-12-01 à 15.22.12](https://us1.discourse-cdn.com/bubble/original/3X/3/1/31f397872d003de04eee4638ae5a6d863c824090.png)

---

<div class="post-metadata">

**Author:** ![georgecollier](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/georgecollier/32/182327_2.png) [@georgecollier](https://forum.bubble.io/u/georgecollier)\
**Post date:** [December 1, 2023, 3:00pm UTC](https://forum.bubble.io/t/group-by-in-table-element/295744/6 "2023-12-01T15:00:45Z")

</div>

Looks like a table bug because you shouoldn’t be able to change the data source to a different data type (Energy version grouped by is different to Energy version)

---

<div class="post-metadata">

**Author:** ![riverogonzalez.isaac](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/riverogonzalez.isaac/32/174136_2.png) [@riverogonzalez.isaac](https://forum.bubble.io/u/riverogonzalez.isaac)\
**Post date:** [December 1, 2023, 3:15pm UTC](https://forum.bubble.io/t/group-by-in-table-element/295744/7 "2023-12-01T15:15:05Z")

</div>

Ok but in the last picture I created a new table with a grouping data type and it does not work either

---

<div class="post-metadata">

**Author:** ![georgecollier](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/georgecollier/32/182327_2.png) [@georgecollier](https://forum.bubble.io/u/georgecollier)\
**Post date:** [December 1, 2023, 3:18pm UTC](https://forum.bubble.io/t/group-by-in-table-element/295744/8 "2023-12-01T15:18:47Z")

</div>

First try with a repeating group. Get an RG. Data source is Search for Energy version 2:grouped by month (interval 3 months). Check ‘do not skip empty groups’. Add an aggregation ‘sum’ for the kWh and cost fields.

In each RG cell, display using text Current cell’s grouping’s sum of kWh and Current cell’s grouping’s sum of cost. This will work. If it doesn’t, you haven’t followed the instructions correctly.

Then, copy and paste the same expression into a new table and add the text fields to the cells. If that doesn’t work, it’s a table issue that you should report to Bubble.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/bubble/original/3X/2/8/2847faa74692c2ffa5d939d3dc3724cdd060d247.png) [@system](https://forum.bubble.io/u/system)\
**Post date:** [February 9, 2024, 12:42pm UTC](https://forum.bubble.io/t/group-by-in-table-element/295744/9 "2024-02-09T12:42:17Z")

</div>

Closed on February 9, 2024, 12:42pm UTC

This topic was automatically closed after 70 days. New replies are no longer allowed.
