Ranking in tables

Hi there I am trying to add a ranking column to a table via a custom column that is similar to the "=RANK" function in Excel.

I have a column called Quantity test (see picture) and based on the values of that column I would like to add another column that ranks all of these values in a new column.

Wondering if that is possible in Retool? Can it directly be done in a calculated field or would I need to use a Transformer? What would be an example of how it is done?

Any help is appreciated!

Hey @Robdawill

There is probably a better way to do this, but something like this seems to work. In this example I use the default Retool table values and make a custom column ranking based on the sales amount.

However - since I did this using a calculated column, I wouldn't be able to access this value easily in a query or elsewhere in my app. If you wanted to use this value elsewhere I would suggest creating an additional column in a transformer.

1 Like

Just realized that I ordered these ranks backwards... works in the other direction as well :slight_smile:

1 Like

@JoeyKarczewski thank you so much for your quick reply I really appreciate it a lot!
However in trying to replicate your solution I am getting the following error:
"table1.data.map is not a function" below I have also included an image.
Not sure if I have missed anything to did something wrong?

Many thanks!

Hi @Robdawill! Is your table data formatted as an array? You may need to try formatDataAsArray(table1.data) in place of table1.data


@Tess @JoeyKarczewski Thank you both for your help! It works :slight_smile:

1 Like