Forum Discussion
Sorting dataentries but keeping separation between subheadings
Hello!
I would like to sort datasets with three columns, but keep the sets separate with different subheadings, but sort them all within themselves. I find it difficult to explain further with words but will attach images. In the first images the datasets are shown as entered and by default are sorted by the leftmost column, as that's how they're entered. I would however like to be able to sort by the right most column, but keep all the datasets separate. I have made a mockup in the second picture to show what I mean. Is this possible?
Thank you in advance!
2 Replies
- IlirUIron Contributor
Hi TFStenberg,
If you run Excel 365 then create a Helper Column (in my data I created it in column D - see screenshot) and in cell F2 apply the following formula.
=LET( data, A2:C34, group, D2:D34, sorted, SORTBY(data, group, 1, INDEX(data,, 3), 1), DROP(VSTACK(TAKE(data, 1), sorted), -1) )Below is the formula that does not require the creation of a Helper Column.
=LET( data, A2:C34, tk, TAKE(data,, -1), group, SCAN(1, IFERROR(SEQUENCE(ROWS(tk)) / ISTEXT(tk), ""), LAMBDA(a,b, IF(b = "", a, b))), sorted, SORTBY(data, group, 1, INDEX(data,, 3), 1), DROP(VSTACK(TAKE(data, 1), sorted), -1) )Hope this helps.
IlirU
- m_tarlerSilver Contributor
If you have another 'grouping' you should include a column with that grouping identification. Then you can sort by that grouping first and the subgroup variable next
here is an example how I did it:
note: I needed to add the 1.1 and 2.1 on those headers to keep them in their places also