# Calculated field add value for each UNIQUE row

**URL:** <https://community.amazonquick.com/t/calculated-field-add-value-for-each-unique-row/23894>\
**Category:** Q&A\
**Tags:** developer, qls-learningdash, quick-sight\
**Created:** [January 18, 2024, 7:00pm UTC](https://community.amazonquick.com/t/calculated-field-add-value-for-each-unique-row/23894 "2024-01-18T19:00:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![japeter89](https://avatars.discourse-cdn.com/v4/letter/j/a9adbd/32.png) [@japeter89](https://community.amazonquick.com/u/japeter89)\
**Post date:** [January 18, 2024, 7:00pm UTC](https://community.amazonquick.com/t/calculated-field-add-value-for-each-unique-row/23894/1 "2024-01-18T19:00:49Z")

</div>

Example:  
I have a dataset of 19,000 rows. 3 rows have id of 123. of those three rows, there is a column dep that has 1 for each. When I get a count of dep its three. but I need count of 1 because the id is the same. How would I do that?  
My thought is that one of the three rows will have 1 and the other 2 would have 0. which would work, but I wouldn’t know how to do that. Thanks!

---

<div class="post-metadata">

**Author:** ![ErikG](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/erikg/32/14524_2.png) [@ErikG](https://community.amazonquick.com/u/ErikG)\
**Post date:** [January 18, 2024, 7:43pm UTC](https://community.amazonquick.com/t/calculated-field-add-value-for-each-unique-row/23894/2 "2024-01-18T19:43:54Z")

</div>

Hi @japeter89  
would be

> **[distinct\_count - Amazon QuickSight](https://docs.aws.amazon.com/quicksight/latest/user/distinct_count-function.html)**
>
> Use the distinct\_count function for calculated fields in Amazon QuickSight analyses.

an option?  
BR

---

<div class="post-metadata">

**Author:** ![japeter89](https://avatars.discourse-cdn.com/v4/letter/j/a9adbd/32.png) [@japeter89](https://community.amazonquick.com/u/japeter89)\
**Post date:** [January 18, 2024, 8:25pm UTC](https://community.amazonquick.com/t/calculated-field-add-value-for-each-unique-row/23894/3 "2024-01-18T20:25:22Z")

</div>

No, that gives me a number of distinct ids, which is 1. but some of the ids might have ‘dep’ equal to 0  
ex:  
id dep  
1 1  
1 1  
2 0  
3 0  
so in this example, I would want the number 1 to return. if I got a unique count of id’s I would get three. and if I got a count of dep’s I would get 2. But im trying to get unique id’s and then add those deps. make sense?

---

<div class="post-metadata">

**Author:** ![ErikG](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/erikg/32/14524_2.png) [@ErikG](https://community.amazonquick.com/u/ErikG)\
**Post date:** [January 18, 2024, 8:43pm UTC](https://community.amazonquick.com/t/calculated-field-add-value-for-each-unique-row/23894/4 "2024-01-18T20:43:08Z")

</div>

> [@japeter89](#):
>
> id dep  
> A 1  
> A 1  
> B 0  
> C 0

You only want the outcome?  
id dep new\_field  
A 1 1  
B 0 0  
C 0 0  
Means count-distinct id where dep=1?

Or what about avgOver id? Do you have 0 and 1 for a ID?

---

<div class="post-metadata">

**Author:** ![ErikG](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/erikg/32/14524_2.png) [@ErikG](https://community.amazonquick.com/u/ErikG)\
**Post date:** [February 1, 2024, 9:33am UTC](https://community.amazonquick.com/t/calculated-field-add-value-for-each-unique-row/23894/5 "2024-02-01T09:33:09Z")

</div>

Hi @japeter89  
Could you solve your issue?  
BR

---

<div class="post-metadata">

**Author:** ![japeter89](https://avatars.discourse-cdn.com/v4/letter/j/a9adbd/32.png) [@japeter89](https://community.amazonquick.com/u/japeter89)\
**Post date:** [February 2, 2024, 10:27pm UTC](https://community.amazonquick.com/t/calculated-field-add-value-for-each-unique-row/23894/6 "2024-02-02T22:27:29Z")

</div>

realizing that I could filter down by adding filters but not including them in the sheet ended up being my resolve.
