# Remove duplicates within the period

**URL:** <https://community.amazonquick.com/t/remove-duplicates-within-the-period/18435>\
**Category:** Q&A\
**Tags:** calculations, quick-sight\
**Created:** [September 19, 2023, 4:15pm UTC](https://community.amazonquick.com/t/remove-duplicates-within-the-period/18435 "2023-09-19T16:15:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yuriy](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/yuriy/32/7618_2.png) [@Yuriy](https://community.amazonquick.com/u/Yuriy)\
**Post date:** [September 19, 2023, 4:15pm UTC](https://community.amazonquick.com/t/remove-duplicates-within-the-period/18435/1 "2023-09-19T16:15:06Z")

</div>

assuming I have following dataset

resourceid, details, timestamp, cost  
111111,aaaaaaa,01-01-2023,100  
111111,aaaaaaa,01-02-2023,100  
111111,aaaaaaa,01-03-2023,100  
111111,aaaaaaa,02-01-2023,100  
111111,aaaaaaa,03-01-2023,100  
111111,aaaaaaa,03-02-2023,100

how can I build a visual (or calc fields) which will show distinct monthly cost per resource. E.g. in this case 100 for Jan, Feb and Mar regardless of how many line items reported within that month. In other words how can I remove duplicates within the month and use only single record for monthly cost calculation?

---

<div class="post-metadata">

**Author:** ![abacon](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/abacon/32/2291_2.png) [@abacon](https://community.amazonquick.com/u/abacon)\
**Post date:** [September 20, 2023, 8:46am UTC](https://community.amazonquick.com/t/remove-duplicates-within-the-period/18435/2 "2023-09-20T08:46:58Z")

</div>

Hi @Yuriy

I built a calculated field **distinctCosts** as follows

```auto
avgOver(avg(cost),[resourceid,truncDate("MM",timestamp),cost])

```

Then I created an analysis as follows:

 ![image](https://d1wl4jav5dp96l.cloudfront.net/original/2X/8/8375d116847c368ae670ccdbce904a67a066dac3.png)

This groups on cost and the month (the truncated date).

Does this help provide a solution?

Many Thanks,  
Andrew
