Is there a way to show DISTINCT or UNIQUE values from a list? Say I have a list of volunteers walking dogs through the day, the same volunteer may walk 3 to 5 dogs, I would like to be able to show only 1 name instead of 3-5 duplicates.
Hi @miroliwosz,
Unfortunately Adalo doesn’t have built-in way to display only unique values in the list.
I can think of 2 workarounds:
- one option is to structure your database in a way so that you have a collection which contains only distinct values by design. E.g. imagine you have Volunteers and Dogs. You can design the app in a way so that Volunteer records to represent each volunteer, and Dogs records represent a unique Dog. Then you can create a 3rd collection “Dog Walks”, in which you store the “connections” between a volunteer and a dog (has a 1:M relation to Volunteer and 1:M relation to a Dog).
In this way you can display unique Volunteers by creating a list of Volunteers.
BTW, storing potential users in a collection different from Users is not the best idea, but this is a different subject. - Another option will be to play with the visibility condition of list items. I’ve decided to make a video about this approach: https://youtu.be/AFgetcqX2qM.
Best,
Victor.
Thanks for taking a look at it, I think i got it to work! It’s a bit slow with many records but it does display them. Also it’s worth mentioning in your video that the list shoulld be set to LOAD ALL ENTRIES as opposed to as user scrolls with large data sets.
The only other thing is, how do I sort by largest to lowest walk count. So essentially this is a leaderboard showing which volunteer has the most walks, so I’d like to display them in order of most walks to least walks.
@miroliwosz I don’t think you can display unique items AND sort the list by walk count. You can try storing walk count as integer in the collection, but the whole “distinct” algorithm of distinct is based on sorting and unique IDs of the records. So I can’t quickly suggest how could you combine 2 requirements here.
In my personal opinion, I’d focus on option 1 instead.
Best,
Victor.
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.