<p>Here is the workaround I've resorted to using in the meantime.</p>

<pre><code>{# Initiate the hash in which we'll store matching submissions. #}
{% set matchingSubmissions = [] %}

{#
    Loop through all submissions, checking if the specified field
    matches the desired value.
#}
{% for submission in submissions if submission.fieldWithValue == '123' %}

    {# If the field matches, add it to the hash #}
    {% set matchingSubmissions = matchingSubmissions|merge([submission.fieldWithValue]) %}

{% endfor %}

{# Count the size of the resulting hash and save it. #}
{% set submissionCount = matchingSubmissions|length %}
</code></pre>

CC BY-SA 3.0
2018-01-25T10:45:59.727Z
2018-01-25T10:45:59.727Z
Sandwich
<p>Unfortunately this currently isn't possible. However, we've added it to the feature requests list and will revisit adding this in the not-too-distant future. :)</p>

CC BY-SA 3.0
2017-12-21T19:33:30.973Z
Drat! I'm converting an EE site that uses that Freeform feature and had expected to be able to do the same things. :-/
Sandwich
CC BY-SA 3.0
2017-12-21T21:28:05.613Z
@solspace I'm just curious... It took me only a few minutes to create that feature with a custom function and a search via Yii Records, why don't you present a workaround even just for this special use case - instead of saying not possible currently?
Robin Schambach
CC BY-SA 3.0
2017-12-24T11:53:45.810Z
I'd love to see a temporary workaround for this...?
Sandwich
CC BY-SA 4.0
2019-05-10T12:21:45.787Z
Is this possible right now? @Solspace
Maarten Heideman
CC BY-SA 4.0
2019-05-13T03:36:31.430Z
An upcoming version will include this (late May 2019)
Solspace
CC BY-SA 3.0
2017-12-21T17:37:10.537Z
2017-12-21T17:37:10.537Z
Solspace
<p>This might not work, but you can try it like so:</p>

<pre><code>{% set submissionCount = craft.freeform.submissions({
    form: 'myAmazingForm',
    fieldWithValue: '123',
}).count() %}
</code></pre>

CC BY-SA 3.0
2017-12-21T17:36:26.733Z
2017-12-21T17:36:26.733Z
carlcs
<p>I need to be able to get a count (in the frontend) of the number of submissions that have a field with a specific value. I don't need the submitted data of the submissions, just the count of submissions whose data matches a specified value.</p>

<p>This code returns the total number of submissions:</p>

<pre><code>{% set submissionCount = craft.freeform.submissions({
    form: 'myAmazingForm'
}).count %}
</code></pre>

<p>I tried using the native Craft search parameter, but it returns zero:</p>

<pre><code>{% set submissionCount = craft.freeform.submissions({
    form: 'myAmazingForm'
}).search('fieldWithValue:123').count %}
</code></pre>

<p>And yes, there <em>are</em> submissions that would match that.</p>

<p>How can I do this?</p>

<search><plugin-freeform><freeform>
Search/Filter Freeform submissions by field value
# Search/Filter Freeform submissions by field value

(Asked by: username_0 on 2017-12-21)

I need to be able to get a count (in the frontend) of the number of submissions that have a field with a specific value. I don't need the submitted data of the submissions, just the count of submissions whose data matches a specified value.
This code returns the total number of submissions:
{% set submissionCount = craft.freeform.submissions({
    form: 'myAmazingForm'
}).count %}

I tried using the native Craft search parameter, but it returns zero:
{% set submissionCount = craft.freeform.submissions({
    form: 'myAmazingForm'
}).search('fieldWithValue:123').count %}

And yes, there are submissions that would match that.
How can I do this?

**Tags:** search, plugin-freeform, freeform


---

## 3 answers

### Answer by username_0 on 2018-01-25. Score: 1 | Accepted answer

Here is the workaround I've resorted to using in the meantime.
{# Initiate the hash in which we'll store matching submissions. #}
{% set matchingSubmissions = [] %}

{#
    Loop through all submissions, checking if the specified field
    matches the desired value.
#}
{% for submission in submissions if submission.fieldWithValue == '123' %}

    {# If the field matches, add it to the hash #}
    {% set matchingSubmissions = matchingSubmissions|merge([submission.fieldWithValue]) %}

{% endfor %}

{# Count the size of the resulting hash and save it. #}
{% set submissionCount = matchingSubmissions|length %}


---

### Answer by username_1 on 2017-12-21. Score: 1

Unfortunately this currently isn't possible. However, we've added it to the feature requests list and will revisit adding this in the not-too-distant future. :)

> **Comments:**
> **username_0**: Drat! I'm converting an EE site that uses that Freeform feature and had expected to be able to do the same things. :-/  
> **username_2**: @solspace I'm just curious... It took me only a few minutes to create that feature with a custom function and a search via Yii Records, why don't you present a workaround even just for this special use case - instead of saying not possible currently?  
> **username_0**: I'd love to see a temporary workaround for this...?  
> **username_3**: Is this possible right now? @username_1  
> **username_1**: An upcoming version will include this (late May 2019)  

---

### Answer by username_4 on 2017-12-21. Score: 1

This might not work, but you can try it like so:
{% set submissionCount = craft.freeform.submissions({
    form: 'myAmazingForm',
    fieldWithValue: '123',
}).count() %}


---

