Jorge Solá 2/10/2022 6:24:49 PM It's possible to set it up so that you only modify the record you want to move up or down the rank (that is, without swapping ranks with the record immediately above or below) if you use a decimal number for the ranking.
I don't use duplicate rankings.
I set up a rank number with 5 decimals.
Then I set up a relation of the table with itself so that each record is linked to the ones above it in the ranking, through a match condition that says: [Rank] < [Rank], Then use the Index function to read the rank of the record immediately above (#1 when sorted by rank in descending order) & 2 records above.
When you click on the "Move Up" button by a record, it simply writes a new value as its rank. This new value is the decimal average rank of the 2 records above.
Example: Record A: Rank 3 Record B: Rank 4 Record C: Rank 5. Record D: Rank 6.
(Initial rank can be the record Id.)
When you "Move Up" record D, it writes 4.5 as its new rank, so it puts it between B & C. If you then "Move Up" record C, it writes 4.25 as its new rank.
If the record is already at the top of the rank, you can set it up so that the button doesn't show.
If the record is in second position, you can write as its new rank a value equal to half the rank of the preceding record.
You can similarly set up the "Move Down" button, or add a "Move to the Top" or "Move to the Bottom" button.
In a case like the one in the Excel sample provided, you can add a [Cuisine] = [Cuisine] matching condition to the relation of the table to itself, so that the rankings for each type of Cuisine are independent.
Then, if you want to display a nice integer ranking for the user (instead of the decimal real ranking), you can set up, in the above relation, a "# of records" function, read how many records have a lower ranking, & set up a Formula - Number column that adds 1 to that figure. That would be the integer ranking of the record.
|