#47 — Sort An EXCEL Table According To Custom Segments
Judith-Excel-Sharing
Posted on August 19, 2024
Problem description & analysis:
An Excel table has three columns:
We want to sort rows of the table according to different segments of the 3rd column in ascending order. The 1st segment: the 3rd column value≤50; the 2nd segment: 700 < the 3rd column value < 720; the 3rd segment: the other cases (50 < the 3rd column value < 700 or the 3rd column value > 720). Below is the expected result:
Solution:
Use SPL XLL to do this:
=spl("=?.enum@n([$[?<=50],$[?>=701 && ?<=720]],~3).conj(~.sort(~3))",A1:C15)
As shown in the picture below:
enum()function performs enumerated grouping according to the value of the specified string expression; $[] represents a string; @ n option enables putting members that do not meet the enumerated conditions in one and separate group. ~ is the current member of a sequence, and ~3 is the 3rd member of a sequence.
Posted on August 19, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
September 5, 2024
August 22, 2024