Answers.Body: <p>You'll want to use:</p>
  
  <pre><code>{% set mylevel = currentUser.level.value %}
  </code></pre>
  
  <p>If you just use <code>currentUser.level</code> and assign it to a variable, then what you'll get back is a <a href="https://craftcms.com/classreference/fieldtypes/MultiOptionsFieldData" rel="nofollow noreferrer">MultiOptionsFieldData</a> class, instead of the value you are expecting.</p>
  
  <p>There is a note on the bottom of the <a href="https://craftcms.com/docs/dropdown-fields" rel="nofollow noreferrer">page here</a> that describes it.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-25T21:26:27.717Z
Answers.LastActivityDate: 2017-01-25T21:26:27.717Z
Answers.UserDisplayName: Brad Bell
Body: <p>I'm not sure if this is a bug or not, but there is something weird going on if I try to compare an integer form a dropdown field to an integer in the template. In short, it doesn't work.</p>
  
  <p>I'm working with a dropdown level field for users from 1 to 15 and use conditionals for content:</p>
  
  <pre><code>{% set integer = 7 %}
  {% set mylevel = currentUser.level %}
  
  My level: {{mylevel}}&lt;br&gt;
  Number: {{integer}}&lt;br&gt;&lt;br&gt;
  
  {% if mylevel &gt;= integer %}
      {{mylevel}} bigger than or equals {{integer}}
  {% else %}
      {{mylevel}} smaller than {{integer}}    
  {% endif %}
  </code></pre>
  
  <p>This outputs:</p>
  
  <pre><code>My level: 8&lt;br&gt;
  Number: 7&lt;br&gt;&lt;br&gt;
  8 smaller than 7
  </code></pre>
  
  <p>HOWEVER if I replace the code "currentUser.level" with 8 like:</p>
  
  <pre><code>{% set integer = 7 %}
  {% set mylevel = 8 %}
  
  My level: {{mylevel}}&lt;br&gt;
  Number: {{integer}}&lt;br&gt;&lt;br&gt;
  
  {% if mylevel &gt;= integer %}
      {{mylevel}} bigger than or equals {{integer}}
  {% else %}
      {{mylevel}} smaller than {{integer}}    
  {% endif %}
  </code></pre>
  
  <p>Then the output is:</p>
  
  <pre><code>My level: 8
  Number: 7
  8 bigger than or equals 7
  </code></pre>
  
  <p>I checked the database and reinserted all numbers, but nothing changes.</p>
  
  <p>Database had this:</p>
  
  <pre><code>{"options":[{"label":"SG1","value":"1","default":""},{"label":"SG2","value":"2","default":""},{"label":"SG3","value":"3","default":""},{"label":"SG4","value":"4","default":""},{"label":"SG5","value":"5","default":""},{"label":"SG6","value":"6","default":""},{"label":"SG7","value":"7","default":""},{"label":"SG8","value":"8","default":""},{"label":"SG9","value":"9","default":""},{"label":"SG10","value":"10","default":""},{"label":"SG11","value":"11","default":""},{"label":"SG12","value":"12","default":""},{"label":"TG01","value":"13","default":""},{"label":"TG02","value":"14","default":""},{"label":"TG03","value":"15","default":""},{"label":"TG04","value":"16","default":""}]}
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-01-25T17:56:56.467Z
Comments.Text: When you output the {{currentUser.level}} in your templates what does it give you?
Comments.UserDisplayName: Jan_dh
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-01-25T19:18:06.527Z
Comments.Text: This outputs 8 as you can see in the second example block
Comments.UserDisplayName: noregt
Tags: <templating><conditional><integer><comparisons>
Title: Comparison with an integer from a dropdown list not working
ThreadText: # Comparison with an integer from a dropdown list not working
  
  (Asked by: username_0 on 2017-01-25)
  
  I'm not sure if this is a bug or not, but there is something weird going on if I try to compare an integer form a dropdown field to an integer in the template. In short, it doesn't work.
  
  I'm working with a dropdown level field for users from 1 to 15 and use conditionals for content:
  
  ```
  {% set integer = 7 %}
  {% set mylevel = currentUser.level %}
  
  My level: {{mylevel}}<br>
  Number: {{integer}}<br><br>
  
  {% if mylevel >= integer %}
      {{mylevel}} bigger than or equals {{integer}}
  {% else %}
      {{mylevel}} smaller than {{integer}}    
  {% endif %}
  
  ```
  
  This outputs:
  
  ```
  My level: 8<br>
  Number: 7<br><br>
  8 smaller than 7
  
  ```
  
  HOWEVER if I replace the code "currentUser.level" with 8 like:
  
  ```
  {% set integer = 7 %}
  {% set mylevel = 8 %}
  
  My level: {{mylevel}}<br>
  Number: {{integer}}<br><br>
  
  {% if mylevel >= integer %}
      {{mylevel}} bigger than or equals {{integer}}
  {% else %}
      {{mylevel}} smaller than {{integer}}    
  {% endif %}
  
  ```
  
  Then the output is:
  
  ```
  My level: 8
  Number: 7
  8 bigger than or equals 7
  
  ```
  
  I checked the database and reinserted all numbers, but nothing changes.
  
  Database had this:
  
  ```
  {"options":[{"label":"SG1","value":"1","default":""},{"label":"SG2","value":"2","default":""},{"label":"SG3","value":"3","default":""},{"label":"SG4","value":"4","default":""},{"label":"SG5","value":"5","default":""},{"label":"SG6","value":"6","default":""},{"label":"SG7","value":"7","default":""},{"label":"SG8","value":"8","default":""},{"label":"SG9","value":"9","default":""},{"label":"SG10","value":"10","default":""},{"label":"SG11","value":"11","default":""},{"label":"SG12","value":"12","default":""},{"label":"TG01","value":"13","default":""},{"label":"TG02","value":"14","default":""},{"label":"TG03","value":"15","default":""},{"label":"TG04","value":"16","default":""}]}
  
  ```
  
  **Tags:** templating, conditional, integer, comparisons
  
  > **Comments:**
  > **username_1**: When you output the {{currentUser.level}} in your templates what does it give you?  
  > **username_0**: This outputs 8 as you can see in the second example block  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2017-01-25. Score: 1 | Accepted answer
  
  You'll want to use:
  
  ```
  {% set mylevel = currentUser.level.value %}
  
  ```
  
  If you just use `currentUser.level` and assign it to a variable, then what you'll get back is a [MultiOptionsFieldData](https://craftcms.com/classreference/fieldtypes/MultiOptionsFieldData) class, instead of the value you are expecting.
  
  There is a note on the bottom of the [page here](https://craftcms.com/docs/dropdown-fields) that describes it.
  
  
  ---
  
  