# Group data in different levels

**URL:** <https://community.amazonquick.com/t/group-data-in-different-levels/42912>\
**Category:** Q&A\
**Tags:** error, developer, quick-sight\
**Created:** [February 21, 2025, 3:41pm UTC](https://community.amazonquick.com/t/group-data-in-different-levels/42912 "2025-02-21T15:41:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![igfasouza](https://avatars.discourse-cdn.com/v4/letter/i/bc8723/32.png) [@igfasouza](https://community.amazonquick.com/u/igfasouza)\
**Post date:** [February 21, 2025, 3:41pm UTC](https://community.amazonquick.com/t/group-data-in-different-levels/42912/1 "2025-02-21T15:41:52Z")

</div>

If I have 3 levels of data, like: Country, state and city.  
If every row in my table is a city info, for example roads names. If I need group data by city, state and country, for example, compare the number of roads in a city with state. Is there a way to do this?

I’m trying to group by state and when I try to compare city values with state I got this error:

 ![image](https://d1wl4jav5dp96l.cloudfront.net/original/3X/8/e/8e7856b519f2ddffbf9395d882b184c6e5354ae5.png)

like:  
calculated\_filed1  
count({roads\_names}, [{state}])

calculated\_field2  
count({roads\_names}, [{country}])

calculated\_filed1 \> calculated\_field2  
Once I try to compare 2 aggregated the calculation field works, but then it not show value:

![image](https://d1wl4jav5dp96l.cloudfront.net/original/3X/f/e/fe0e6504aad25f3281d2dd43e5a87f9968943ba6.png)

---

<div class="post-metadata">

**Author:** ![Brett](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/brett/32/36494_2.png) [@Brett](https://community.amazonquick.com/u/Brett)\
**Post date:** [February 21, 2025, 8:54pm UTC](https://community.amazonquick.com/t/group-data-in-different-levels/42912/2 "2025-02-21T20:54:07Z")

</div>

Hi @igfasouza,  
When dealing with errors like this, like mismatched aggregations, you’ll have to incorporate the usage of [Level-Aware Calculations (LAC)](https://community.amazonquick.com/t/level-aware-calculations-tips-and-best-practices/17936).  
Looking at your calculated fields, I would suggest that you explore the [CountOver function](https://docs.aws.amazon.com/quicksight/latest/user/countOver-function.html) as opposed to the regular ‘count’.

Let me know if this works for your case or if you have additional questions.

---

<div class="post-metadata">

**Author:** ![Brett](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/brett/32/36494_2.png) [@Brett](https://community.amazonquick.com/u/Brett)\
**Post date:** [March 4, 2025, 9:38pm UTC](https://community.amazonquick.com/t/group-data-in-different-levels/42912/3 "2025-03-04T21:38:31Z")

</div>

Hi @igfasouza,  
Following back up here as it’s been awhile since we last heard from you; did you have any additional questions regarding your post?

If we do not hear back within the next 3 business days, I’ll close out this topic.

Thank you!

---

<div class="post-metadata">

**Author:** ![Brett](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/brett/32/36494_2.png) [@Brett](https://community.amazonquick.com/u/Brett)\
**Post date:** [March 7, 2025, 10:06pm UTC](https://community.amazonquick.com/t/group-data-in-different-levels/42912/4 "2025-03-07T22:06:08Z")

</div>

Hi @igfasouza,  
Since we have not heard back, I’ll go ahead and close out this topic. However, if you have any additional questions, feel free to create a new post in the community and link this discussion for relevant information if needed.

Thank you!
