<p>Can't something like this help you?</p>

<pre><code>{% for block in entry.myMatrixField.type('fruits').ligthswitchField(params) %}
</code></pre>

CC BY-SA 3.0
2015-11-12T14:56:20.157Z
Lightswitch field is a matrix block in matrix field `fruits`.
Dominik Krulak
CC BY-SA 3.0
2015-11-12T14:59:10.943Z
Sorry, not understanding the question properly :)
Oli
CC BY-SA 3.0
2016-01-04T19:47:31.273Z
You basically got my point at the first time. Didn't see that, after browsing through all my questions.
Dominik Krulak
CC BY-SA 3.0
2015-11-12T14:46:48.173Z
2015-11-12T14:46:48.173Z
Oli
<p>I think, I've cracked it. I haven't tough of concatenating matrix block within the loop and set parameters right in the source.</p>

<pre><code>{% for block in entry.productSettings.type('finish').inStock('1').limit(1) %}
    {{ block.amazonUri }}
{% endfor %}
</code></pre>

<p>It gives first true element in the loop.</p>

CC BY-SA 3.0
2015-11-14T15:41:34.447Z
2015-11-14T15:41:34.447Z
Dominik Krulak
<p>I've run into situation, where I have to loop only once, if condition has met the requirements. The condition is controlled by matrix block field <code>ligthswitch</code> which is the field in <code>finish</code>.</p>

<p>Matrix structure:
<a href="https://i.sstatic.net/vC6JD.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/vC6JD.png" alt="enter image description here"></a></p>

<p>Actually, I've ended up doing this:</p>

<pre><code>{% for block in entry.productSettings.type('finish') %}
   {% if block.inStock %}
      {{ block.amazonUri }}
   {% endif %}
{% endfor %}
</code></pre>

<p>which outputs cluster of characters: <code>123456</code>.
Bear in mind, that total count of characters is count of loops. Desire output is <code>1</code>.</p>

CC BY-SA 3.0
2015-11-12T15:12:02.630Z
Could you provide a little more information on how your matrix is structured? A screenshot would be useful!
kcolls
<matrix>
Output first matching matrix block model if condition is true
# Output first matching matrix block model if condition is true

(Asked by: username_0 on 2015-11-12)

I've run into situation, where I have to loop only once, if condition has met the requirements. The condition is controlled by matrix block field ligthswitch which is the field in finish.
Matrix structure:

Actually, I've ended up doing this:
{% for block in entry.productSettings.type('finish') %}
   {% if block.inStock %}
      {{ block.amazonUri }}
   {% endif %}
{% endfor %}

which outputs cluster of characters: 123456.
Bear in mind, that total count of characters is count of loops. Desire output is 1.

**Tags:** matrix

> **Comments:**
> **username_1**: Could you provide a little more information on how your matrix is structured? A screenshot would be useful!  

---

## 2 answers

### Answer by username_2 on 2015-11-12. Score: 3 | Accepted answer

Can't something like this help you?
{% for block in entry.myMatrixField.type('fruits').ligthswitchField(params) %}

> **Comments:**
> **username_0**: Lightswitch field is a matrix block in matrix field `fruits`.  
> **username_2**: Sorry, not understanding the question properly :)  
> **username_0**: You basically got my point at the first time. Didn't see that, after browsing through all my questions.  

---

### Answer by username_0 on 2015-11-14. Score: 0

I think, I've cracked it. I haven't tough of concatenating matrix block within the loop and set parameters right in the source.
{% for block in entry.productSettings.type('finish').inStock('1').limit(1) %}
    {{ block.amazonUri }}
{% endfor %}

It gives first true element in the loop.


---

