Hi,
the data type is Product and contains the field votes, which is a list of users (figure 1 below)
I would like the repeating group for Product to be filtered by a dropdown menu containing the 4 following options :
- (no filter)
- Created date (newest to oldest)
- Created date (oldest to newest)
- Number of votes (highest to lowest)
I can filter the repeating group for the first 3 options using the conditionals tab (figure 2).
To filter by Number of votes (highest to lowest), I understand I have to use
Sort by ā Change which field and somehow pick Dynamic field name : Dropdown Product sortās value (?? ) (figure 2)
I donāt understand how this is supposed to work since a count of unique users has to be performed within the field votes for each Product row before the sorting takes place. The field votes does not appear anywhere in the search.
Thanks for your help.
K.
figure 1:
figure 2:
To sort by number of votes youāll need to have a number field on your product datatype to store the number of votesā¦
Just update that number every time a new vote is registeredā¦
(By the way, I wouldnāt recommend using a list of users on the product datatype, so Iād suggest getting rid of that field, and using a separate datatype to store votes).
In terms of having a drop-down to determine how to sort the RG, my recommendation would be to create an option set, with your 4 sort options, each with a text attribute for the field name, and a yes/no attribute for descendingā¦
Then just set your sort to the dropdownās value⦠no need to use any conditional data sources or sortingā¦
@adamhholmes - One of the reasons I created a list of users on the product datatype for the votes field is to perform checks so that each user upvotes a product not more than one time.
-
Could you briefly outline what the fields of the āseparate datatype to store votesā look like ?
-
From a DB performance point of view, will your DB tables structure suggestion be the most efficient way to sort and display say hundreds of products by number of votes for which thousands of users vote on ?
Thanks.
K.
The āVoteā datatype will need, as a minimum, a field for āUserā (which will probably just be the Created By filed, but depending exactly on your use case may need to be an additional User filed), and a Product field (of type āProductā).
Of course it can also include any additional data you need to store about the specific vote.
- From a DB performance point of view, will your DB tables structure suggestion be the most efficient way to sort and display say hundreds of products by number of votes for which thousands of users vote on ?
Yes, without question⦠the number of votes is irrelevant⦠itās just a single Number fieldā¦
1 Like