# How to analysis new user vs repeater without multiple count and create a dimension with logs

**URL:** <https://community.amazonquick.com/t/how-to-analysis-new-user-vs-repeater-without-multiple-count-and-create-a-dimension-with-logs/29817>\
**Category:** Q&A\
**Tags:** bar-chart, calculations, Business-Intelligence-Engineer, quick-sight\
**Created:** [May 14, 2024, 8:58am UTC](https://community.amazonquick.com/t/how-to-analysis-new-user-vs-repeater-without-multiple-count-and-create-a-dimension-with-logs/29817 "2024-05-14T08:58:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lisa](https://avatars.discourse-cdn.com/v4/letter/l/f08c70/32.png) [@Lisa](https://community.amazonquick.com/u/Lisa)\
**Post date:** [May 14, 2024, 8:58am UTC](https://community.amazonquick.com/t/how-to-analysis-new-user-vs-repeater-without-multiple-count-and-create-a-dimension-with-logs/29817/1 "2024-05-14T08:58:58Z")

</div>

I have over a thousand rows in the data table below and am trying to create a stacked bar chart. The chart is grouped by new users/repeaters, with the x-axis representing the datehour [month], and the y-axis representing the number of users.

> user id | date(timestamp) | item

I’ve tried use below but…

> First timestamp = minOver(timestamp, [{user id}], PRE\_AGG)  
> New user or repeater = ifelse(timestamp = {First Timestamp}, ‘New User’, ‘Repeater’)

When the same user buys items many times in the same month, the user number is double-counted as both of new users/repeaters… how can I resolve this? I only need new user count the first month

---

<div class="post-metadata">

**Author:** ![WLS-DM](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/wls-dm/32/36109_2.png) [@WLS-DM](https://community.amazonquick.com/u/WLS-DM)\
**Post date:** [May 14, 2024, 3:38pm UTC](https://community.amazonquick.com/t/how-to-analysis-new-user-vs-repeater-without-multiple-count-and-create-a-dimension-with-logs/29817/2 "2024-05-14T15:38:52Z")

</div>

Hello @Lisa, rather then checking for their first timestamp, you should check if their min timestamp is equal to their max. That will ensure a repeat user isn’t counted for their first timestamp and their most recent. It would look something like this:

```auto
ifelse(
minOver(timestamp, [{user_id}], PRE_AGG) = maxOver(timestamp, [{user_id}], PRE_AGG), 
'New User',
minOver(timestamp, [{user_id}], PRE_AGG) <> maxOver(timestamp, [{user_id}], PRE_AGG),
'Repeat User',
NULL
)

```

That should resolve the issue you are facing and should only account for each user\_id once. I’ll mark this as the solution, but please let me know if you have any remaining questions!

---

<div class="post-metadata">

**Author:** ![Lisa](https://avatars.discourse-cdn.com/v4/letter/l/f08c70/32.png) [@Lisa](https://community.amazonquick.com/u/Lisa)\
**Post date:** [May 15, 2024, 9:37am UTC](https://community.amazonquick.com/t/how-to-analysis-new-user-vs-repeater-without-multiple-count-and-create-a-dimension-with-logs/29817/3 "2024-05-15T09:37:33Z")

</div>

It’s still causing problem. for example,

> user id | date(timestamp) | item  
> 001 | 2024-04-01 00:00:00.000+0000 | itemA  
> 001 | 2024-04-09 00:00:00.000+0000 | itemA  
> 002 | 2024-04-04 00:00:00.000+0000 | itemA  
> 002 | 2024-04-27 00:00:00.000+0000 | itemA  
> 003 | 2024-04-29 00:00:00.000+0000 | itemA

when if I try to provide monthly report for itemA on April  
NewUser counted 1 and Repeater counted 2 by this calculation field… how can I avoid this…?

---

<div class="post-metadata">

**Author:** ![WLS-DM](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/wls-dm/32/36109_2.png) [@WLS-DM](https://community.amazonquick.com/u/WLS-DM)\
**Post date:** [May 18, 2024, 10:18pm UTC](https://community.amazonquick.com/t/how-to-analysis-new-user-vs-repeater-without-multiple-count-and-create-a-dimension-with-logs/29817/4 "2024-05-18T22:18:30Z")

</div>

Hello @Lisa, I am a little confused by your question. In the sample data you provided above, users 001 and 002 have 2 timestamps for itemA and user 003 has 1 timestamp for itemA. That looks like 2 repeat users and 1 new. Is there something I am missing? What would you expect the return value to be?
