Answers.Body: <p>That is most likely happening because <code>usage</code> is ambiguous for your <code>logos</code> field, so Craft isn’t sure which column to assign the condition to. If you give the <code>usage</code> field within your <code>img</code> block type a different handle, you should get reliable results.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-19T16:42:34.837Z
Answers.Text: Thanks, Brandon. That makes sense and gets a better outcome. Although, having done that, when I `{% set negLogo = org.logos.usage('monoNeg').one() %}` the returned results are the **total number** of rows in the field, but when I `{% set negLogo = org.logos.usage('monoNeg').all() %}` the returned results are **1**, which is what I want, but the opposite of how I would expect to get there!
Answers.UserDisplayName: Jonathan Schofield
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-19T16:56:52.483Z
Answers.Text: So, even though `.all()` is what returns a single result, I'm doing the following just in case it's ever more than 1: `{% for logo in negLogos|slice(0) %}`.
Answers.UserDisplayName: Jonathan Schofield
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-19T16:31:43.650Z
Answers.LastActivityDate: 2019-03-19T16:31:43.650Z
Answers.UserDisplayName: Brandon Kelly
Body: <p>I have 2 Matrix fields in an entry type, both of which use Dropdown fields:</p>
  
  <pre><code>Matrix: urls
      address (block type)
          context (dropdown field values include 'own')
          address
          urn
  
  Matrix: logos
     svg (block type)
          usage (dropdown field values include 'monoNeg')
          aspectRatio
          svg (source code)
     img (block type)
          usage (equivalent dropdown field)
          img
  </code></pre>
  
  <p>Entries are assigned to a <code>footer</code> Globals field, from which I'm pairing a <strong>urls</strong> value with a <strong>logos</strong> value in a loop to write linked logos.</p>
  
  <p>I can get the relevant URL easily enough with:</p>
  
  <pre><code>{% for org in footer.footerAccreditations %}
      {% set orgUrl = org.urls.context('own').one() %}
      {{ orgUrl.address }}
  {% endfor %}
  </code></pre>
  
  <p>Which prints the <code>address</code> URL just fine.</p>
  
  <p>But the same approach for the <code>svg</code> logo isn't working. Either one of the following returns <code>0</code>, even when I know for sure that the <code>org</code> entry in question has a <code>monoNeg</code> SVG source.</p>
  
  <pre><code>{% set negLogoDirect = org.logos.usage('monoNeg').one() %}
  {{ negLogoDirect|length }}
  
  {% set negLogoTyped = org.logos.type('svg').usage('monoNeg').one() %}
  {{ negLogoTyped|length }}
  </code></pre>
  
  <p>If I run through an <code>all</code> loop for the logos their <code>usage</code> reports exactly as I would expect:</p>
  
  <pre><code>{% set orgLogos = org.logos.all() %}
  
  {% for logo in orgLogos %}
      {{ logo.usage }}
  {% endfor %}
  </code></pre>
  
  <p>I assume I can make my template more verbose and get what I need, but I don't see why the same approach should work for one Matrix dropdown field and not for another.</p>
  
  <p>Where am I going wrong?</p>
  
Tags: <matrix><drop-down>
Title: Craft 3: fetching a single Matrix row by its dropdown field value
ThreadText: # Craft 3: fetching a single Matrix row by its dropdown field value
  
  (Asked by: username_0 on 2019-03-19)
  
  I have 2 Matrix fields in an entry type, both of which use Dropdown fields:
  
  ```
  Matrix: urls
      address (block type)
          context (dropdown field values include 'own')
          address
          urn
  
  Matrix: logos
     svg (block type)
          usage (dropdown field values include 'monoNeg')
          aspectRatio
          svg (source code)
     img (block type)
          usage (equivalent dropdown field)
          img
  
  ```
  
  Entries are assigned to a `footer` Globals field, from which I'm pairing a **urls** value with a **logos** value in a loop to write linked logos.
  
  I can get the relevant URL easily enough with:
  
  ```
  {% for org in footer.footerAccreditations %}
      {% set orgUrl = org.urls.context('own').one() %}
      {{ orgUrl.address }}
  {% endfor %}
  
  ```
  
  Which prints the `address` URL just fine.
  
  But the same approach for the `svg` logo isn't working. Either one of the following returns `0`, even when I know for sure that the `org` entry in question has a `monoNeg` SVG source.
  
  ```
  {% set negLogoDirect = org.logos.usage('monoNeg').one() %}
  {{ negLogoDirect|length }}
  
  {% set negLogoTyped = org.logos.type('svg').usage('monoNeg').one() %}
  {{ negLogoTyped|length }}
  
  ```
  
  If I run through an `all` loop for the logos their `usage` reports exactly as I would expect:
  
  ```
  {% set orgLogos = org.logos.all() %}
  
  {% for logo in orgLogos %}
      {{ logo.usage }}
  {% endfor %}
  
  ```
  
  I assume I can make my template more verbose and get what I need, but I don't see why the same approach should work for one Matrix dropdown field and not for another.
  
  Where am I going wrong?
  
  **Tags:** matrix, drop-down
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-03-19. Score: 2 | Accepted answer
  
  That is most likely happening because `usage` is ambiguous for your `logos` field, so Craft isn’t sure which column to assign the condition to. If you give the `usage` field within your `img` block type a different handle, you should get reliable results.
  
  > **Comments:**
  > **username_0**: Thanks, username_1. That makes sense and gets a better outcome. Although, having done that, when I `{% set negLogo = org.logos.usage('monoNeg').one() %}` the returned results are the **total number** of rows in the field, but when I `{% set negLogo = org.logos.usage('monoNeg').all() %}` the returned results are **1**, which is what I want, but the opposite of how I would expect to get there!  
  > **username_0**: So, even though `.all()` is what returns a single result, I'm doing the following just in case it's ever more than 1: `{% for logo in negLogos|slice(0) %}`.  
  
  ---
  
  