sumOver value changes when removing a group by field

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:

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:

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!

1 Like

Hi @jnorion

Welcome to QuickSight Community .

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

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

1 Like

@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!