Possible to count unique items in a repeater?

Is it possible to count the number of unique values in a repeater column?

As a simplified example, if I had a repeater which contained the following values:

  • Banana
  • Strawberry
  • Strawberry
  • Vanilla
  • Chocolate
  • Vanilla
  • Chocolate
  • Chocolate
  • Banana

I would like to display summary text such as, “4 flavors found” above the repeater.

My real use case would have dozens of different items, so using conditions to check for specific values probably isn’t feasible. Can someone point me in the right direction? Thanks in advance for any ideas.

When the repeater loads an item, you can have it check to see if the item’s value is in a variable. If it isn’t, you append that value to the variable along with a comma (or whatever delimiter you want).

Once the repeater finishes loading, have it fire off an event that loops through the list of values stored in the variable. I did it by setting a widget to execute the following whenever it was moved:

If var_Flavors contains ","
Set var_FlavorCount to "[[Target.text + 1]]
Set var_Flavors to [[var_Flavors.slice((var_Flavors.IndexOf(',') + 1),var_Flavors.length)]]
Move widget by (0,0)

Essentially what it’s doing is counting the number of times a flavor is removed from the variable until the variable is empty.

Count_Unique_In_Repeater.rp (55.6 KB)

1 Like

Thank you so much for taking the time to help and for providing an example file, huban! As a relative newbie to Axure, this is definitely not an approach I would have thought of but it works beautifully.

No problem!
Axure is a very powerful tool, but it does have a bit of a learning curve when you start getting into complex interactions.