# How to get the count from the visuals

**URL:** <https://community.amazonquick.com/t/how-to-get-the-count-from-the-visuals/13453>\
**Category:** Q&A\
**Tags:** calculations, quick-sight\
**Created:** [May 15, 2023, 12:28pm UTC](https://community.amazonquick.com/t/how-to-get-the-count-from-the-visuals/13453 "2023-05-15T12:28:06Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![harsh13799](https://avatars.discourse-cdn.com/v4/letter/h/e99b99/32.png) [@harsh13799](https://community.amazonquick.com/u/harsh13799)\
**Post date:** [May 15, 2023, 12:28pm UTC](https://community.amazonquick.com/t/how-to-get-the-count-from-the-visuals/13453/1 "2023-05-15T12:28:07Z")

</div>

Hi, I am new to quicksight. I need some help to make a calculate field. The basic requirement is to get “% of users taking a practice test more than one time” (289/total user).  
So, by using visualization I am able to get the total 289 count of users. but I am unable to achieve the using a single calculated field.

INFORMATION: I am using 3 columns. CMSUSERID, RESOURCEID, EVENTTYPE(‘Score Test’).  
Please refer the below screenshot of analyses.

 ![image](https://d1wl4jav5dp96l.cloudfront.net/original/2X/a/aef636d49d1fb3e19b3b9fa6af95ceea22d6211a.png)

---

<div class="post-metadata">

**Author:** ![Max](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/max/32/2288_2.png) [@Max](https://community.amazonquick.com/u/Max)\
**Post date:** [May 15, 2023, 9:23pm UTC](https://community.amazonquick.com/t/how-to-get-the-count-from-the-visuals/13453/2 "2023-05-15T21:23:36Z")

</div>

Are you saying you want 289 on all of your rows?

Or are you saying you want the count to be 289 without having to filter?

For the second option you can do this.

`countIf({CMSUSERID}, {EVENTTYPE}='Score Test' AND countOver({CMSUSERID},[{CMSUSERID},{RESOURCEID}],PRE_AGG)>1)`

---

<div class="post-metadata">

**Author:** ![harsh13799](https://avatars.discourse-cdn.com/v4/letter/h/e99b99/32.png) [@harsh13799](https://community.amazonquick.com/u/harsh13799)\
**Post date:** [May 16, 2023, 4:54am UTC](https://community.amazonquick.com/t/how-to-get-the-count-from-the-visuals/13453/3 "2023-05-16T04:54:45Z")

</div>

Hi @Max, thank you for your reply.

your logic is correct but I am getting 4737 counts. Here are a few more details.

The total distinct user count is **891**.  
The distinct user count who has ‘Score Test’ event type is **329** group by resourceid.  
The distinct user count who has ‘Score Test’ even type more than 1 time group by resourceid is **289**.

using your calculated field, it is giving me **4737**.

countIf({CMSUSERID}, {EVENTTYPE}=‘Score Test’ AND countOver({CMSUSERID},[{CMSUSERID},{RESOURCEID}],PRE\_AGG)\>1) = **4737**

distinct\_countIf({CMSUSERID}, {EVENTTYPE}=‘Score Test’ AND countOver({CMSUSERID},[{CMSUSERID},{RESOURCEID}],PRE\_FILTER) \> 1) = **329**

distinct\_countIf(CMSUSERID, countOver(CMSUSERID,[CMSUSERID,RESOURCEID],PRE\_AGG) \> 1) = **289** with using filter EVENTTYPE equals to Score Test.

I need % of users. So, I need to divide the **289** counts with **891**. I am able to achieve the count(289) in one calculated field but as here I am using EVENTTYPE filter, if I add another calculated field for distinct users, it is dividing users by 329 instead of 891.

 ![image](https://d1wl4jav5dp96l.cloudfront.net/original/2X/5/5356f8084dba759f01afd4bb7a71ea25a0ba7992.png)

---

<div class="post-metadata">

**Author:** ![Max](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/max/32/2288_2.png) [@Max](https://community.amazonquick.com/u/Max)\
**Post date:** [May 16, 2023, 4:21pm UTC](https://community.amazonquick.com/t/how-to-get-the-count-from-the-visuals/13453/4 "2023-05-16T16:21:36Z")

</div>

If you don’t add eventtype=‘Score Test’ to this one does it get you 891?

distinct\_countIf({CMSUSERID}, {EVENTTYPE}=‘Score Test’ AND countOver({CMSUSERID},[{CMSUSERID},{RESOURCEID}],PRE\_FILTER) \> 1)?

---

<div class="post-metadata">

**Author:** ![harsh13799](https://avatars.discourse-cdn.com/v4/letter/h/e99b99/32.png) [@harsh13799](https://community.amazonquick.com/u/harsh13799)\
**Post date:** [May 16, 2023, 5:02pm UTC](https://community.amazonquick.com/t/how-to-get-the-count-from-the-visuals/13453/5 "2023-05-16T17:02:57Z")

</div>

If you don’t add eventtype=‘Score Test’ to this one does it get you 891? → **Yes**

distinct\_countIf({CMSUSERID}, {EVENTTYPE}=‘Score Test’ AND countOver({CMSUSERID},[{CMSUSERID},{RESOURCEID}],PRE\_FILTER) \> 1)? → **329**

---

<div class="post-metadata">

**Author:** ![Max](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/max/32/2288_2.png) [@Max](https://community.amazonquick.com/u/Max)\
**Post date:** [May 16, 2023, 5:11pm UTC](https://community.amazonquick.com/t/how-to-get-the-count-from-the-visuals/13453/6 "2023-05-16T17:11:11Z")

</div>

Great! Can you use that calculated field?

---

<div class="post-metadata">

**Author:** ![harsh13799](https://avatars.discourse-cdn.com/v4/letter/h/e99b99/32.png) [@harsh13799](https://community.amazonquick.com/u/harsh13799)\
**Post date:** [May 16, 2023, 6:20pm UTC](https://community.amazonquick.com/t/how-to-get-the-count-from-the-visuals/13453/7 "2023-05-16T18:20:54Z")

</div>

No sir, I can’t use the same calculated field(891 count), as I have already applied filter to the parent calculated field(289).

To be more clear I need 289(score test filter)/891(total cmsuser count).

---

<div class="post-metadata">

**Author:** ![Max](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/max/32/2288_2.png) [@Max](https://community.amazonquick.com/u/Max)\
**Post date:** [May 16, 2023, 7:28pm UTC](https://community.amazonquick.com/t/how-to-get-the-count-from-the-visuals/13453/8 "2023-05-16T19:28:46Z")

</div>

Why do you need to apply the filter?

Will the 289 be 289 if you take off the filter?

---

<div class="post-metadata">

**Author:** ![harsh13799](https://avatars.discourse-cdn.com/v4/letter/h/e99b99/32.png) [@harsh13799](https://community.amazonquick.com/u/harsh13799)\
**Post date:** [May 17, 2023, 2:42am UTC](https://community.amazonquick.com/t/how-to-get-the-count-from-the-visuals/13453/9 "2023-05-17T02:42:56Z")

</div>

No sir, if i remove the filter then the count increase to 329.

---

<div class="post-metadata">

**Author:** ![Max](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/max/32/2288_2.png) [@Max](https://community.amazonquick.com/u/Max)\
**Post date:** [May 17, 2023, 1:49pm UTC](https://community.amazonquick.com/t/how-to-get-the-count-from-the-visuals/13453/10 "2023-05-17T13:49:16Z")

</div>

> [@harsh13799](#):
>
> distinct\_countIf(CMSUSERID, countOver(CMSUSERID,[CMSUSERID,RESOURCEID],PRE\_AGG) \> 1) = **289** with using filter EVENTTYPE equals to Score Test.

Why don’t you add a condition of if event type is equal to Score Test as well in the calculated field?

---

<div class="post-metadata">

**Author:** ![harsh13799](https://avatars.discourse-cdn.com/v4/letter/h/e99b99/32.png) [@harsh13799](https://community.amazonquick.com/u/harsh13799)\
**Post date:** [May 17, 2023, 1:53pm UTC](https://community.amazonquick.com/t/how-to-get-the-count-from-the-visuals/13453/11 "2023-05-17T13:53:25Z")

</div>

Because even if I add event type is equal to the score test, it is giving me **329** count. so, If I add it as a filter then it gives me desired count **289**.

---

<div class="post-metadata">

**Author:** ![Max](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/max/32/2288_2.png) [@Max](https://community.amazonquick.com/u/Max)\
**Post date:** [May 17, 2023, 2:09pm UTC](https://community.amazonquick.com/t/how-to-get-the-count-from-the-visuals/13453/12 "2023-05-17T14:09:39Z")

</div>

To confirm you’ve made a calculated field that says this.

```auto
distinct_countIf(CMSUSERID, {EVENTTYPE}=‘Score Test’ AND countOver(CMSUSERID,[CMSUSERID,RESOURCEID],PRE_AGG) > 1)

```

And it is not what you are looking for?

You also will need to add the eventtype in your countOver.

```auto
distinct_countIf(CMSUSERID, {EVENTTYPE}=‘Score Test’ AND countOver(ifelse({EVENTTYPE}=
Score Test', CMSUSERID,NULL),[CMSUSERID,RESOURCEID],PRE_AGG) > 1)

```

---

<div class="post-metadata">

**Author:** ![harsh13799](https://avatars.discourse-cdn.com/v4/letter/h/e99b99/32.png) [@harsh13799](https://community.amazonquick.com/u/harsh13799)\
**Post date:** [May 17, 2023, 2:15pm UTC](https://community.amazonquick.com/t/how-to-get-the-count-from-the-visuals/13453/13 "2023-05-17T14:15:49Z")

</div>

> [@Max](#):
>
> ```auto
> distinct_countIf(CMSUSERID, {EVENTTYPE}=‘Score Test’ AND countOver(ifelse({EVENTTYPE}=
> Score Test', CMSUSERID,NULL),[CMSUSERID,RESOURCEID],PRE_AGG) > 1)
> 
> ```

It worked for me! Thank you very much @Max. It is great learning for me.
