Answers.Body: <p>Something like this should do the trick:</p>
  
  <pre><code>{% set usersGroupedByCountry = craft.users.limit(null)|group('postaddress.country') %}
  
  &lt;ul&gt;
      {% for country, users in usersGroupedByCountry %}
          {% if country and users|length %}
             &lt;li&gt;{{ country }} ({{ users|length }})&lt;/li&gt;
          {% endif %}   
      {% endfor %}
  &lt;/ul&gt;
  </code></pre>
  
  <p>Note that if you want to order the list of countries, you'll need the <a href="https://github.com/TopShelfCraft/SuperSort">SuperSort plugin</a>. Here's how you would sort the list alphabetically:</p>
  
  <pre><code>{% set usersGroupedByCountry = craft.users.limit(null)|group('postaddress.country)|supersort('ksort') %}
  </code></pre>
  
  <p>Also note that if you have a lot of users (say, hundreds), it is probably a good idea to wrap the whole thing (including the <code>{% set usersGroupedByCountry ... %}</code> part) in a <a href="https://craftcms.com/docs/templating/cache"><code>{% cache %}</code></a> tag pair, for performance reasons.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-10-16T12:48:40.383Z
Answers.Text: Thanks Mats, it works perfectly. The only addition I added was the lower filter on postaddress.country because of the different way of writing. (United States, united states, United states, UNITED STATES)
Answers.UserDisplayName: John Stevens
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-29T01:09:30.030Z
Answers.LastActivityDate: 2016-09-29T01:09:30.030Z
Answers.UserDisplayName: Mats Mikkel Rummelhoff
Body: <p>We are building a family community website with more than 600 members all over the world.</p>
  
  <p>In <strong>craft.users</strong> we have added many fields and one of them is <strong>country</strong>.</p>
  
  <p>We want to display and count all countries.</p>
  
  <p><strong>Example of the desired output could be something like:</strong></p>
  
  <p>Our members are living in the next 5 countries</p>
  
  <ul>
  <li>the Netherlands (545)</li>
  <li>Chili (26)</li>
  <li>USA (14)</li>
  <li>Italy (6)</li>
  <li>Sweden (8)</li>
  </ul>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-09-28T20:00:56.200Z
Comments.Text: You may want to provide _much_ more detail than that... We know nothing about your site's architecture. Are countries being stored as Categories, related Entries, or plain text values? Is the country field associated directly with the Users, or via a separate Entry?
Comments.UserDisplayName: Lindsey D
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-09-28T21:53:29.500Z
Comments.Text: Is the `country` field on your Users field layout?  If so, what type of field is it?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-09-28T22:40:51.000Z
Comments.Text: For the users address I use Smart Map so the country is like 'postaddress.country'
Comments.UserDisplayName: John Stevens
Tags: <templating><filter>
Title: Count all unique values
ThreadText: # Count all unique values
  
  (Asked by: username_0 on 2016-09-28)
  
  We are building a family community website with more than 600 members all over the world.
  
  In **craft.users** we have added many fields and one of them is **country**.
  
  We want to display and count all countries.
  
  **Example of the desired output could be something like:**
  
  Our members are living in the next 5 countries
  
  * the Netherlands (545)
  * Chili (26)
  * USA (14)
  * Italy (6)
  * Sweden (8)
  
  **Tags:** templating, filter
  
  > **Comments:**
  > **username_1**: You may want to provide _much_ more detail than that... We know nothing about your site's architecture. Are countries being stored as Categories, related Entries, or plain text values? Is the country field associated directly with the Users, or via a separate Entry?  
  > **username_2**: Is the `country` field on your Users field layout?  If so, what type of field is it?  
  > **username_0**: For the users address I use Smart Map so the country is like 'postaddress.country'  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_3 on 2016-09-29. Score: 5 | Accepted answer
  
  Something like this should do the trick:
  
  ```
  {% set usersGroupedByCountry = craft.users.limit(null)|group('postaddress.country') %}
  
  <ul>
      {% for country, users in usersGroupedByCountry %}
          {% if country and users|length %}
             <li>{{ country }} ({{ users|length }})</li>
          {% endif %}   
      {% endfor %}
  </ul>
  
  ```
  
  Note that if you want to order the list of countries, you'll need the [SuperSort plugin](https://github.com/TopShelfCraft/SuperSort). Here's how you would sort the list alphabetically:
  
  ```
  {% set usersGroupedByCountry = craft.users.limit(null)|group('postaddress.country)|supersort('ksort') %}
  
  ```
  
  Also note that if you have a lot of users (say, hundreds), it is probably a good idea to wrap the whole thing (including the `{% set usersGroupedByCountry ... %}` part) in a [`{% cache %}`](https://craftcms.com/docs/templating/cache) tag pair, for performance reasons.
  
  > **Comments:**
  > **username_0**: Thanks username_3, it works perfectly. The only addition I added was the lower filter on postaddress.country because of the different way of writing. (United States, united states, United states, UNITED STATES)  
  
  ---
  
  