# Using an if() condition calculation to calculate the count() whcih is passed to repeat\_count?

**URL:** <https://forum.getodk.org/t/using-an-if-condition-calculation-to-calculate-the-count-whcih-is-passed-to-repeat-count/58641>\
**Category:** Support\
**Created:** [October 3, 2026, 10:00am UTC](https://forum.getodk.org/t/using-an-if-condition-calculation-to-calculate-the-count-whcih-is-passed-to-repeat-count/58641 "2026-10-03T10:00:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jurrefws](https://getodk.b-cdn.net/letter_avatar_proxy/v4/letter/j/db5fbb/32.png) [@jurrefws](https://forum.getodk.org/u/jurrefws)\
**Post date:** [October 3, 2026, 10:00am UTC](https://forum.getodk.org/t/using-an-if-condition-calculation-to-calculate-the-count-whcih-is-passed-to-repeat-count/58641/1 "2026-10-03T10:00:06Z")

</div>

**1. What is the issue? Please be detailed.**  
if(${trans\_type} = 'out' and ${select\_reason} = 'sale' , count(instance('linking\_check')/root/data[uuid = ${reason\_uuid}]/product) , ' ')  
I am using the following formula , it is working fine but when the trans\_type and select\_reason changes to anything other where i want that there should be no repeat\_count limit and the repeat group works manualy , it is not showing the repeat group.

**3. What have you tried to fix the issue?  
check on forum but can't find any solution.**

**4. Upload any forms or screenshots you can share publicly below.**

---

<div class="post-metadata">

**Author:** ![wroos](https://getodk.b-cdn.net/letter_avatar_proxy/v4/letter/w/77aa72/32.png) [@wroos](https://forum.getodk.org/u/wroos)\
**Post date:** [October 3, 2026, 11:23am UTC](https://forum.getodk.org/t/using-an-if-condition-calculation-to-calculate-the-count-whcih-is-passed-to-repeat-count/58641/2 "2026-10-03T11:23:40Z")

</div>

As far as I know there is no option to "deactivate" the repeat\_count (limit) like this.

A workaround might be to work with an entry field where the user can manually set a number for the repeat count. This field can be controlled by your if clause, either by required or calculation with once() as preset.

Then the repeat\_count could use or combine the information, based on your if-calculation with else value from this manual field. (Might also be a max or min use case?)

---

<div class="post-metadata">

**Author:** ![ahblake](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/ahblake/32/22392_2.png) [@ahblake](https://forum.getodk.org/u/ahblake)\
**Post date:** [October 5, 2026, 12:09am UTC](https://forum.getodk.org/t/using-an-if-condition-calculation-to-calculate-the-count-whcih-is-passed-to-repeat-count/58641/3 "2026-10-05T00:09:35Z")

</div>

I wonder if this is related to [not removing repeat elements](https://docs.getodk.org/form-logic/#hiding-extra-repeats-when-the-repeat-count-is-reduced) if repeat count is decreased.

> **bad idea**
>
> I hesitate to suggest this as it's pretty messy, but it might deliver what you are looking for with current functionality.
> 
> - one repeat that uses the repeat count `count(instance('linking_check')/root/data[uuid = ${reason_uuid}]/product)` and repeat relevance `${trans_type} = 'out' and ${select_reason} = 'sale'`
> - another repeat with no repeat count and repeat relevance `${trans_type} != 'out' or ${select_reason} != 'sale'`
> - duplicate the questions in both repeats
> - use a third repeat with the count set as that of the relevant repeat
> - for each repeat element position, calculate in the value for the question from the matching position from the relevant repeat.

Actually, [this](https://docs.getodk.org/form-logic/#repeating-as-long-as-a-condition-is-met) is probably a much better solution, but modify the repeat\_count expression to something like this, where it's set to your lookup count for the out&sale case, but the user can keep +1-ing more entries for the other case.  
`if(${trans_type} = 'out' and ${select_reason} = 'sale' , count(instance('linking_check')/root/data[uuid = ${reason_uuid}]/product) , if(${count} = 0 or ${plant}[position()=${count}]/more_plants = 'yes', ${count} + 1, ${count}))`
