# How do I count occurrences in an array column?

**URL:** <https://community.glideapps.com/t/how-do-i-count-occurrences-in-an-array-column/30553>\
**Category:** Ask for Help\
**Created:** [August 16, 2021, 5:36pm UTC](https://community.glideapps.com/t/how-do-i-count-occurrences-in-an-array-column/30553 "2021-08-16T17:36:23Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jonathon\_Kohn](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jonathon_kohn/32/8593_2.png) [@Jonathon\_Kohn](https://community.glideapps.com/u/Jonathon_Kohn)\
**Post date:** [August 16, 2021, 5:36pm UTC](https://community.glideapps.com/t/how-do-i-count-occurrences-in-an-array-column/30553/1 "2021-08-16T17:36:23Z")

</div>

I’ve got a user ID and and item ID joined into a template column that is then fed into a list column and set as the buy button’s product ID/SKU.

I’m allowing clients to add multiple items to their cart prior to checking out and need to count how often an item ID occurs in the array column that is formed from splitting the list column.

Is there a way to count occurrences?

 ![Screen Shot 2021-08-16 at 12.36.03 PM](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/0/c/0c3f88c499063269fb6b56e838969d649136e4d4.png)  
within an array column yet?

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [August 16, 2021, 5:40pm UTC](https://community.glideapps.com/t/how-do-i-count-occurrences-in-an-array-column/30553/2 "2021-08-16T17:40:49Z")

</div>

Have you tried a rollup?

> [@new Rollups, Single Values and JoinLists FROM ARRAYS!](https://community.glideapps.com/t/rollups-single-values-and-joinlists-from-arrays/29634):
>
> You’ve always been able to create Rollup columns, Single Value Columns and Join List columns from a multiple relation or an entire sheet, but now you can create them from an ARRAY COLUMN!

Or are you trying to get something like 2,1,1 out of the array?

---

<div class="post-metadata">

**Author:** ![Jonathon\_Kohn](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jonathon_kohn/32/8593_2.png) [@Jonathon\_Kohn](https://community.glideapps.com/u/Jonathon_Kohn)\
**Post date:** [August 16, 2021, 7:58pm UTC](https://community.glideapps.com/t/how-do-i-count-occurrences-in-an-array-column/30553/3 "2021-08-16T19:58:26Z")

</div>

I’m trying to get just “2” from that first value that is seen twice.

---

<div class="post-metadata">

**Author:** ![Lucas\_Pires](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/lucas_pires/32/64863_2.png) [@Lucas\_Pires](https://community.glideapps.com/u/Lucas_Pires)\
**Post date:** [August 16, 2021, 9:30pm UTC](https://community.glideapps.com/t/how-do-i-count-occurrences-in-an-array-column/30553/5 "2021-08-16T21:30:38Z")

</div>

@Jonathon_Kohn Well, I dont know your cenario, but I tried to replicate it.

You have this first relation I called `rel/ items`. Having this, you could try:

- **Relation** from IDs to the unique IDs in the other sheet;
- **Rollup** to count the unique IDs from this 2nd relation;

The 2 steps below I’m not sure if you need it, but I made it anyway:

- **If-Then-Else** to hide zeros - when rollup equals 0 then blank, else rollup;
- **Join list** from If-Then-Else to get the occurrences separeted by commas;

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/e/a/eae3773e1925f82c9b9953daba642e8bbff7d9af.png)

---

<div class="post-metadata">

**Author:** ![Jonathon\_Kohn](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jonathon_kohn/32/8593_2.png) [@Jonathon\_Kohn](https://community.glideapps.com/u/Jonathon_Kohn)\
**Post date:** [August 16, 2021, 9:45pm UTC](https://community.glideapps.com/t/how-do-i-count-occurrences-in-an-array-column/30553/6 "2021-08-16T21:45:30Z")

</div>

See above screenshot. I want to count the number of times an ID occurs within an array column. The array column here is 2 comma separated lists combined into 1 column then split into an array. I want to count the times each ID occurs within that single column.

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [August 16, 2021, 9:53pm UTC](https://community.glideapps.com/t/how-do-i-count-occurrences-in-an-array-column/30553/7 "2021-08-16T21:53:44Z")

</div>

I think I have a Yes Code column almost ready to sent your way. Just to confirm, do you have this one in a comma-delimited format instead of an array?

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [August 16, 2021, 10:38pm UTC](https://community.glideapps.com/t/how-do-i-count-occurrences-in-an-array-column/30553/8 "2021-08-16T22:38:12Z")

</div>

![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/9/f/9f5ac72dfd012eb2089b3bed14602f0eb055dbc0.png)

I believe what you need is this, right?

---

<div class="post-metadata">

**Author:** ![Jonathon\_Kohn](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jonathon_kohn/32/8593_2.png) [@Jonathon\_Kohn](https://community.glideapps.com/u/Jonathon_Kohn)\
**Post date:** [August 16, 2021, 11:02pm UTC](https://community.glideapps.com/t/how-do-i-count-occurrences-in-an-array-column/30553/9 "2021-08-16T23:02:18Z")

</div>

Exactly… is that not currently possible without the code column?

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [August 16, 2021, 11:02pm UTC](https://community.glideapps.com/t/how-do-i-count-occurrences-in-an-array-column/30553/10 "2021-08-16T23:02:30Z")

</div>

Comma-delimited version:

> **[Notion – The all-in-one workspace for your notes, tasks, wikis, and databases.](https://www.notion.so/glidecommunity/6b1c20a4d6f0464780710481453d1ddf?v=80d0287f4cc4411abb3bc5b3977739c7&p=f511d7cbdeb846149ef12b6b810160c0)**
>
> A new tool that blends your everyday work apps into one. It's the all-in-one workspace for you and your team

Array version:

> **[Notion – The all-in-one workspace for your notes, tasks, wikis, and databases.](https://www.notion.so/glidecommunity/6b1c20a4d6f0464780710481453d1ddf?v=80d0287f4cc4411abb3bc5b3977739c7&p=7c2efa6fb99340789fdfe5e275782292)**
>
> A new tool that blends your everyday work apps into one. It's the all-in-one workspace for you and your team

Enjoy 😉

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [August 16, 2021, 11:03pm UTC](https://community.glideapps.com/t/how-do-i-count-occurrences-in-an-array-column/30553/11 "2021-08-16T23:03:14Z")

</div>

Ah I can’t immediately think of a solution without using the XC column but the links are there in the reply above, just plug it in and run!

---

<div class="post-metadata">

**Author:** ![Lucas\_Pires](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/lucas_pires/32/64863_2.png) [@Lucas\_Pires](https://community.glideapps.com/u/Lucas_Pires)\
**Post date:** [August 16, 2021, 11:10pm UTC](https://community.glideapps.com/t/how-do-i-count-occurrences-in-an-array-column/30553/12 "2021-08-16T23:10:06Z")

</div>

> [@ThinhDinh](#):
>
> just plug it in and run!

Love this phrase! 👊🏼💥

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [August 16, 2021, 11:11pm UTC](https://community.glideapps.com/t/how-do-i-count-occurrences-in-an-array-column/30553/13 "2021-08-16T23:11:29Z")

</div>

One of the best things about XC/YC column eh 😉

---

<div class="post-metadata">

**Author:** ![Mns\_Glide](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/mns_glide/32/2514_2.png) [@Mns\_Glide](https://community.glideapps.com/u/Mns_Glide)\
**Post date:** [October 30, 2022, 3:42am UTC](https://community.glideapps.com/t/how-do-i-count-occurrences-in-an-array-column/30553/14 "2022-10-30T03:42:18Z")

</div>

With all the new updates, is there a way to find occurrences in array without XC column? I have been trying all the array formulas in new column type, but unable to come up with solution.

Appreciate feedback.

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [October 30, 2022, 6:46am UTC](https://community.glideapps.com/t/how-do-i-count-occurrences-in-an-array-column/30553/15 "2022-10-30T06:46:19Z")

</div>

yeah…

- Use the Remove Element from Array plugin to remove all instances of the item you want to count
- You now have two arrays; the original, and the smaller one with the item to be counted removed
- Do a rollup on each to get a count of items
- The difference between the two counts is the number of your items in the original array
