# How to count item by condition?

**URL:** <https://community.glideapps.com/t/how-to-count-item-by-condition/36595>\
**Category:** Ask for Help\
**Created:** [January 2, 2022, 3:38pm UTC](https://community.glideapps.com/t/how-to-count-item-by-condition/36595 "2022-01-02T15:38:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Manuelle\_GUSTAVE](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/manuelle_gustave/32/35548_2.png) [@Manuelle\_GUSTAVE](https://community.glideapps.com/u/Manuelle_GUSTAVE)\
**Post date:** [January 2, 2022, 3:38pm UTC](https://community.glideapps.com/t/how-to-count-item-by-condition/36595/1 "2022-01-02T15:38:50Z")

</div>

Hi,

I would like to do an app to shuffle items and add them into a TodoList.  
I have 2 lists bucket1 & bucket2  
I added an button with a custom action to shuffle and add an item in my TodoList i would like to hide the button if i have 3 items of bucket1 in TodoList and 2 bucket2 in TodoList  
How i can count how many items where list = bucket1 and in TodoList?

Thanks

---

<div class="post-metadata">

**Author:** ![Robert\_Petitto](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/robert_petitto/32/25193_2.png) [@Robert\_Petitto](https://community.glideapps.com/u/Robert_Petitto)\
**Post date:** [January 2, 2022, 4:41pm UTC](https://community.glideapps.com/t/how-to-count-item-by-condition/36595/2 "2022-01-02T16:41:13Z")

</div>

Depends how your data is set up.

I would set it up this way:

1. A users table
2. A table with a master list of todo items
3. A table that assigns todo items to a bucket for each user

The button should add a row to the third table. It should write the todo item, the email of the signed in user, and the bucket number. In this same table, create two if then else columns

1. “If Bucket A”: If bucket is A then 1 else 0
2. “If Bucket B”: If bucket is B then 1 else 0

In the users table, create a multiple relation to table 3 via email address. Then do a Rollup (sum) of the “If Bucket A” column. Create a second Rollup (sum) of the “If Bucket B” column.

You now have two columns that count how many task items belong in each bucket for each user. Use these as visibility conditions for showing/hiding the button.

---

<div class="post-metadata">

**Author:** ![Manuelle\_GUSTAVE](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/manuelle_gustave/32/35548_2.png) [@Manuelle\_GUSTAVE](https://community.glideapps.com/u/Manuelle_GUSTAVE)\
**Post date:** [January 3, 2022, 8:31am UTC](https://community.glideapps.com/t/how-to-count-item-by-condition/36595/3 "2022-01-03T08:31:47Z")

</div>

Hi Robert,

Thank you for your response, i will try
