Answers.Body: <p>According to <a href="https://craftcms.stackexchange.com/a/2357/130">this answer</a> the only ways to filter matrix blocks are by type, or by position. So you need to use the <code>if</code> condition on the <a href="http://twig.sensiolabs.org/doc/tags/for.html" rel="nofollow noreferrer">twig for tag</a>.</p>
  
  <pre><code>{% for m in entry.myMatrix if m.theName == nameImLookingFor %}
    {% if loop.index == 1 %}
      got the first one, it is {{m.theName}}
    {% endif %}
  {% endfor %}
  </code></pre>
  
  <p>If you don't want to loop over all of the blocks, you can also install the <a href="https://github.com/marionnewlevant/craft-mnbreakandcontinue" rel="nofollow noreferrer">mnbreakandcontinue plugin</a> and break out of the loop after the first match:</p>
  
  <pre><code>{% for m in entry.myMatrix if m.theName == nameImLookingFor %}
    got the first one, it is {{m.theName}}
    {% break %}
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-27T19:36:45.023Z
Answers.Text: And according to Brandon's comment [here](http://craftcms.stackexchange.com/questions/39/search-matrix-for-blocks-with-upcoming-dates/41#comment5242_41), things will change with Craft 2.3! Really good news...
Answers.UserDisplayName: carlcs
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-27T19:57:33.473Z
Answers.Text: Awesome thanks! and thanks for mentioning the 'mnbreakandcontinue' plugin :)
Answers.UserDisplayName: Lea Hayes
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-11-27T19:30:51.587Z
Answers.LastActivityDate: 2014-11-27T19:30:51.587Z
Answers.LastEditDate: 2017-04-13T12:51:00.303Z
Answers.UserDisplayName: Marion Newlevant
Body: <p>If I have a matrix field with 2 fields "Name" and "Entry" is it possible to lookup the first row in that matrix field which has a specific "Name"?</p>
  
  <p>Context: Twig template.</p>
  
Tags: <templating><matrix>
Title: Lookup row in matrix field by "Name" column?
ThreadText: # Lookup row in matrix field by "Name" column?
  
  (Asked by: username_0 on 2014-11-27)
  
  If I have a matrix field with 2 fields "Name" and "Entry" is it possible to lookup the first row in that matrix field which has a specific "Name"?
  
  Context: Twig template.
  
  **Tags:** templating, matrix
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2014-11-27. Score: 3 | Accepted answer
  
  According to [this answer](https://craftcms.stackexchange.com/a/2357/130) the only ways to filter matrix blocks are by type, or by position. So you need to use the `if` condition on the [twig for tag](http://twig.sensiolabs.org/doc/tags/for.html).
  
  ```
  {% for m in entry.myMatrix if m.theName == nameImLookingFor %}
    {% if loop.index == 1 %}
      got the first one, it is {{m.theName}}
    {% endif %}
  {% endfor %}
  
  ```
  
  If you don't want to loop over all of the blocks, you can also install the [mnbreakandcontinue plugin](https://github.com/username_1/craft-mnbreakandcontinue) and break out of the loop after the first match:
  
  ```
  {% for m in entry.myMatrix if m.theName == nameImLookingFor %}
    got the first one, it is {{m.theName}}
    {% break %}
  {% endfor %}
  
  ```
  
  > **Comments:**
  > **username_2**: And according to Brandon's comment [here](http://craftcms.stackexchange.com/questions/39/search-matrix-for-blocks-with-upcoming-dates/41#comment5242_41), things will change with Craft 2.3! Really good news...  
  > **username_0**: Awesome thanks! and thanks for mentioning the 'mnbreakandcontinue' plugin :)  
  
  ---
  
  