Looks like there's a Craft 2 plugin that exposes PHP's array_unique method to Twig.
So to continue on the example you linked to, it would be something like this with that plugin installed:
{# Initiate the hash in which we'll store matching submissions. #}
{% set matchingSubmissions = [] %}
{#
Loop through all submissions, checking if the specified field
matches the desired value.
#}
{% for submission in submissions if submission.fieldWithValue == '123' %}
{# If the field matches, add it to the hash #}
{% set matchingSubmissions = matchingSubmissions|merge([submission.fieldWithValue]) %}
{% endfor %}
{# Count the size of the resulting hash and save it. #}
{% set totalUniques = matchingSubmissions|unique|length %}