# sumOver value changes when removing a group by field

**URL:** <https://community.amazonquick.com/t/sumover-value-changes-when-removing-a-group-by-field/35348>\
**Category:** Q&A\
**Tags:** calculations, Business-Intelligence-Engineer, quick-sight\
**Created:** [September 18, 2024, 12:27am UTC](https://community.amazonquick.com/t/sumover-value-changes-when-removing-a-group-by-field/35348 "2024-09-18T00:27:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jnorion](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/jnorion/32/24341_2.png) [@jnorion](https://community.amazonquick.com/u/jnorion)\
**Post date:** [September 18, 2024, 12:27am UTC](https://community.amazonquick.com/t/sumover-value-changes-when-removing-a-group-by-field/35348/1 "2024-09-18T00:27:24Z")

</div>

I’m working with a dataset of building energy use, and related metadata. Along with the actual energy use, each row contains a building name and the area (size) of the building in square feet. There are many rows for each building, but neither the name nor the area change. Here’s an example of what the data looks like:

| Building | Energy use | Area |
| --- | --- | --- |
| Building 1 | 12345 | 500 |
| Building 1 | 64312 | 500 |
| Building 1 | 98275 | 500 |
| Building 2 | 44587 | 700 |
| Building 2 | 80121 | 700 |
| Building 3 | 22341 | 400 |
| Building 3 | 67452 | 400 |
| Building 3 | 43215 | 400 |

I need to calculate the total area of all the buildings, i.e. 500 + 700 + 400. To do this, I created a calculated field called `Area - total portfolio`. The code for that is:

```auto
sumOver(max(Area))

```

I exported a CSV of `Building` and `Area` (per building) so I could check the math, and the correct total area (for my real data) is 17,964,032 square feet. When I create a table with `Area - total portfolio` as a value and group by `Building`, I get the correct sum. However, if I remove the group by field, the result changes, even though I’ve made no other changes to the dataset or visual or anything else:

 ![Screenshots](https://d1wl4jav5dp96l.cloudfront.net/original/3X/0/5/0550afb787f42b858928719a30a44e66f296ea0b.png)

Can anyone tell my why this would no longer be correct? I need to use this in other calculations, and anytime I reference it in a calculated field it gives me the lower, incorrect answer.

Thanks!

---

<div class="post-metadata">

**Author:** ![apjvinod](https://avatars.discourse-cdn.com/v4/letter/a/8baadc/32.png) [@apjvinod](https://community.amazonquick.com/u/apjvinod)\
**Post date:** [September 18, 2024, 3:50am UTC](https://community.amazonquick.com/t/sumover-value-changes-when-removing-a-group-by-field/35348/2 "2024-09-18T03:50:40Z")

</div>

Hi @jnorion

Welcome to Quick Sight Community .

Would recommend to visit Quick Sight learning series on effectively using Quick Sight Level Aware calculations .

[![](https://d1wl4jav5dp96l.cloudfront.net/original/2X/7/72f48a1976abbdcdf0deb0eff83bdbe839b45d54.jpeg "Basic Calculations: 2023 Amazon QuickSight Learning Series") ](https://www.youtube.com/watch?v=KPBHp3VaKXE)

[![](https://d1wl4jav5dp96l.cloudfront.net/original/2X/c/cebcce203f065fa8e5d836b8e4fdc06afa226445.jpeg "Advanced Calculations: 2023 Amazon QuickSight Learning Series") ](https://www.youtube.com/watch?v=k5qPPIJlOSU&t=552s)

> **[DemoCentral](https://democentral.learnquicksight.online/#Dashboard-FeatureDemo-Calculation-Level-Aware-Calculations)**

In this example .. you may create the expression as below to calculate the max area at the building level first and then doing sum .

sum(max(Area,[Building]))

Thanks  
Vinod

---

<div class="post-metadata">

**Author:** ![jnorion](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/jnorion/32/24341_2.png) [@jnorion](https://community.amazonquick.com/u/jnorion)\
**Post date:** [September 18, 2024, 4:10pm UTC](https://community.amazonquick.com/t/sumover-value-changes-when-removing-a-group-by-field/35348/3 "2024-09-18T16:10:38Z")

</div>

@apjvinod Awesome, that worked perfectly. Now I’ll go back and watch the videos to try to understand _why_ it worked.

Thank you for the help!
