Sorting Data

mummbles74

Board Regular
Joined
Nov 14, 2009
Messages
120
Office Version
  1. 365
Platform
  1. Windows
I have read a million different web pages and lost myself down a thousand rabit holes and I am not sure this is even possible but what I am looking to do is sort data by ascending values in Column Y but keep duplicate values in Column A together.

As a very crude example I would want the finished table to look like this:
TagRisk Rank
120
111
219
212
318
317
313
414
413

With it originally looking like this:

TagRisk Rank
120
219
318
317
414
313
413
212
111
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
It can be done from your menu bar 'Sort and Filter' by 'Custom Sorting' indicating two levels.
Select 'With Headings' then for the first level select column 'Tag', sort 'A-Z' then add second level with column 'Risk Rank', sort 'Z-A'.
 
Last edited:
Upvote 0
Sorry, my crude example made it appear simpler than it is. The tag numbers may not always be in ascending order when sorted by risk rank.

So original data like this:
TagRisk Rank
220
319
118
217
414
313
413
212
111

I would want it to look like this:

TagRisk Rank
220
217
212
319
313
118
111
414
413
 
Upvote 0
How about this...sort by risk rank, pull unique tags, and then join all ranks.
scratchbook excel testing.xlsm
ABCDE
1TagRisk RankTagRisk Rank
2220220, 17, 12
3319319, 13
4118118, 11
5217414, 13
6414
7313
8413
9212
10111
Sheet22
Cell Formulas
RangeFormula
D2:D5D2=UNIQUE($A$2:$A$10)
E2:E5E2=TEXTJOIN(", ",TRUE,IF($A$2:$A$10=D2,$B$2:$B$10,""))
Dynamic array formulas.
 
Upvote 0
What version of Excel are you using?

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0
The tag numbers may not always be in ascending order when sorted by risk rank.
Sorry, I have no idea how to handle it unless you use a macro, but what a problem would there be to have the 'Tag' column sorted ?
 
Upvote 0
If you have the 365 (see fluff above) - but I generally do this for my own amusement anyway.

MrExcelPlayground8-1.xlsx
ABCDE
1TagRisk RankTagRisk Rank
2111219
3212212
4313115
5413111
6414414
7310413
8310313
9219310
10115310
Sheet20
Cell Formulas
RangeFormula
D2:E10D2=LET(a,UNIQUE(A2:A10),b,MAXIFS(B2:B10,A2:A10,a),c,SORTBY(a,b,-1),d,SEQUENCE(ROWS(c)),e,XLOOKUP(A2:A10,c,d),SORTBY(A2:B10,e,,B2:B10,-1))
Dynamic array formulas.
 
Upvote 0
Sorry, I have no idea how to handle it unless you use a macro, but what a problem would there be to have the 'Tag' column sorted ?
I am happy to use a Macro if you know code that will work. All help appreciated
 
Upvote 0
What version of Excel are you using?

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
Updated thank you.
 
Upvote 0
If you have the 365 (see fluff above) - but I generally do this for my own amusement anyway.
James Thank you for this I managed to use the formula above, modified it slightly to reflect the maximum range of data that I have and it gives me everything I needed. The only improvement I would like to make is to assist with the next stages of what the complete sheet does.
The hole reason for sorting the data this way is so that duplicate tag numbers can then be remerged reflecting the highest risk range so that clients can prioritise their repairs. All of this works fine, what I would like to do is be able to count the rows in Column A of the maintenance Data sheet that have a tag number (can be text or number) and replace this count in place of the 20000 row number in the formula. is this at all possible either with a formula or VBA?

=LET(a,UNIQUE('Maintenance Data'!$A$2:$A$20000),b,MAXIFS('Maintenance Data'!$Y$2:$Y$20000,'Maintenance Data'!$A$2:$A$20000,a),c,SORTBY(a,b,-1),d,SEQUENCE(ROWS(c)),e,XLOOKUP('Maintenance Data'!$A$2:$A$20000,c,d),SORTBY('Maintenance Data'!$A$2:$Y$20000,e,,'Maintenance Data'!$Y$2:$Y$20000,-1))

Thanks for all the support so far everyone, I am just 1 step away, I think
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,915
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top