#51 - Get Rankings of Excel Rows in Each Group While Retaining the Existing Order

Problem description & analysis:

We have an unordered Excel table, where the 1st column is the grouping column and the 2nd column contains dates.

Task: Get rankings of rows in each group and write them in the 3rd column while retaining the exis…


This content originally appeared on DEV Community and was authored by Judith-Excel-Sharing

Problem description & analysis:

We have an unordered Excel table, where the 1st column is the grouping column and the 2nd column contains dates.

original table

Task: Get rankings of rows in each group and write them in the 3rd column while retaining the existing order of the rows. The expected result is as follows:

desired table

Solution:

Use SPL XLL to do this:

=spl("=E(?).derive(#:id,rk).sort(#1,#2).run(rk=rank(#2;#1)).sort(id).(rk)",A1:B14)

As shown in the picture below:

result table with code entered
Explanation:

E()function converts the Excel data range to a table. derive() function adds a new column. rank() function gets rankings of records in each sorted group. # is the row number and #1 represents the 1st column.


This content originally appeared on DEV Community and was authored by Judith-Excel-Sharing


Print Share Comment Cite Upload Translate Updates
APA

Judith-Excel-Sharing | Sciencx (2024-08-26T07:05:48+00:00) #51 - Get Rankings of Excel Rows in Each Group While Retaining the Existing Order. Retrieved from https://www.scien.cx/2024/08/26/51-get-rankings-of-excel-rows-in-each-group-while-retaining-the-existing-order/

MLA
" » #51 - Get Rankings of Excel Rows in Each Group While Retaining the Existing Order." Judith-Excel-Sharing | Sciencx - Monday August 26, 2024, https://www.scien.cx/2024/08/26/51-get-rankings-of-excel-rows-in-each-group-while-retaining-the-existing-order/
HARVARD
Judith-Excel-Sharing | Sciencx Monday August 26, 2024 » #51 - Get Rankings of Excel Rows in Each Group While Retaining the Existing Order., viewed ,<https://www.scien.cx/2024/08/26/51-get-rankings-of-excel-rows-in-each-group-while-retaining-the-existing-order/>
VANCOUVER
Judith-Excel-Sharing | Sciencx - » #51 - Get Rankings of Excel Rows in Each Group While Retaining the Existing Order. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/08/26/51-get-rankings-of-excel-rows-in-each-group-while-retaining-the-existing-order/
CHICAGO
" » #51 - Get Rankings of Excel Rows in Each Group While Retaining the Existing Order." Judith-Excel-Sharing | Sciencx - Accessed . https://www.scien.cx/2024/08/26/51-get-rankings-of-excel-rows-in-each-group-while-retaining-the-existing-order/
IEEE
" » #51 - Get Rankings of Excel Rows in Each Group While Retaining the Existing Order." Judith-Excel-Sharing | Sciencx [Online]. Available: https://www.scien.cx/2024/08/26/51-get-rankings-of-excel-rows-in-each-group-while-retaining-the-existing-order/. [Accessed: ]
rf:citation
» #51 - Get Rankings of Excel Rows in Each Group While Retaining the Existing Order | Judith-Excel-Sharing | Sciencx | https://www.scien.cx/2024/08/26/51-get-rankings-of-excel-rows-in-each-group-while-retaining-the-existing-order/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.