SORT(UNIQUE issue

ollyhughes1982

Well-known Member
Joined
Nov 27, 2018
Messages
677
Office Version
  1. 365
Platform
  1. MacOS
Hi,

Re screenshot below:

Screenshot 2021-11-17 at 01.00.36.png


I have the below formula to give results in column B:

=IFERROR(SORT(UNIQUE(FILTER('All Completed VS'!C4:C2003,'All Completed VS'!E4:E2003<>"")),,-1),"")

In column C I then have:

=IF(B4="","",MAXIFS('All Completed VS'!$AZ$4:$AZ$2003,'All Completed VS'!$C$4:$C$2003,B4))

...which gives me the count for the values in column B.

Is there a way that I can change the sort so that the list shows in descending order of the values in column C? (i.e. Newport [10] at the top, then Riverfront [8], Penallta [4] and so on...) At the moment I can only get it to sort by column B. This just gives an alphabetical sort of column B.

Thanks in advance!
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Hi,

since you are on 365, you can first build your table included the events and the counts, then use unique and finally sort on 2 indexes.

Technique shown below. You would need to adapt the formulas inside LET to your needs. I do believe it should be doable in a single let formula. It's still very new to me.

Book1
ABCDEFGHI
1river4
21new10s1
32river8pen4
43pen4wint
54ponty3ponty1
65pontp2river6
76seven2river
87p1t1
98r1river8
109s1river1
1110t1wint1
1211wint1pen3
1312wool1river3
14seven2
15new7
16r1
17new3
18river5
19ponty2
20new4
21new1
22r
23t
24ponty
25pontp2
26p
27new6
28river7
29pen2
30new5
31pen1
32wool1
33new9
34wool
35pontp1
36new10
37new8
38ponty3
39s
40new
41river2
42p1
43seven1
44new2
45seven
Sheet1
Cell Formulas
RangeFormula
A2:A13A2=SEQUENCE(ROWS(B2#))
B2:C13B2=SORT(UNIQUE(LET(Events,FILTER(H1:H45,I1:I45<>""), Cnts,MAXIFS(I1:I45,H1:H45,Events), Col,SEQUENCE(1,2), IFS(Col=1,Events,Col=2,Cnts))),{2;1},{-1;1})
Dynamic array formulas.
 
Upvote 0
Hi,

since you are on 365, you can first build your table included the events and the counts, then use unique and finally sort on 2 indexes.

Technique shown below. You would need to adapt the formulas inside LET to your needs.

Book1
ABCDEFGHI
1river4
21new10s1
32river8pen4
43pen4wint
54ponty3ponty1
65pontp2river6
76seven2river
87p1t1
98r1river8
109s1river1
1110t1wint1
1211wint1pen3
1312wool1river3
14seven2
15new7
16r1
17new3
18river5
19ponty2
20new4
21new1
22r
23t
24ponty
25pontp2
26p
27new6
28river7
29pen2
30new5
31pen1
32wool1
33new9
34wool
35pontp1
36new10
37new8
38ponty3
39s
40new
41river2
42p1
43seven1
44new2
45seven
Sheet1
Cell Formulas
RangeFormula
A2:A13A2=SEQUENCE(ROWS(B2#))
B2:C13B2=SORT(UNIQUE(LET(Events,FILTER(H1:H45,I1:I45<>""), Cnts,MAXIFS(I1:I45,H1:H45,Events), Col,SEQUENCE(1,2), IFS(Col=1,Events,Col=2,Cnts))),{2;1},{-1;1})
Dynamic array formulas.
Hi. Thanks for this, but I cannot resort the table. It is a table that is added to all the time and is always in date order that events / roles are completed.
 
Upvote 0
Hi. Thanks for this, but I cannot resort the table. It is a table that is added to all the time and is always in date order that events / roles are completed.
Now I'm confused as your query is to sort the result based on the count. That's exactly what my formula does.
 
Upvote 0
Now I'm confused as your query is to sort the result based on the count. That's exactly what my formula does.
Apologies, I was thinking that the original source worksheet had to be rearranged? I cannot rearrange the source data, it stays in date completed order. I will try your formula now. Could you possibly try your solution within my file, so that the references will correct for that table, please?
 
Upvote 0
Apologies, I was thinking that the original source worksheet had to be rearranged?
No, I simply used your formulas inside the let function.
Could you possibly try your solution within my file, so that the references will correct for that table, please?
try
Excel Formula:
SORT(
UNIQUE(
LET(
Events;FILTER('All Completed VS'!C4:C2003,'All Completed VS'!E4:E2003<>"");
Cnts;MAXIFS('All Completed VS'!$AZ$4:$AZ$2003,'All Completed VS'!$C$4:$C$2003,Events);
Col;SEQUENCE(1;2);
IFS(Col=1;Events;Col=2;Cnts)
)
)
;{2;1};{-1;1})
 
Upvote 0
Solution
Apologies, I was thinking that the original source worksheet had to be rearranged? I cannot rearrange the source data, it stays in date completed order. I will try your formula
No, I simply used your formulas inside the let function.

try
Excel Formula:
SORT(
UNIQUE(
LET(
Events;FILTER('All Completed VS'!C4:C2003,'All Completed VS'!E4:E2003<>"");
Cnts;MAXIFS('All Completed VS'!$AZ$4:$AZ$2003,'All Completed VS'!$C$4:$C$2003,Events);
Col;SEQUENCE(1;2);
IFS(Col=1;Events;Col=2;Cnts)
)
)
;{2;1};{-1;1})
Entering this into cell B4 gives me an error. Screenshot below:
Screenshot 2021-11-17 at 09.07.44.jpg

If I include the CODE parts, the formula just doesn't do anything.
 
Upvote 0
I am on EU settings, so I use ";" where you are using using ",".
 
Upvote 0
Cool, glad I could help and thanks for the mark.
 
Upvote 0

Forum statistics

Threads
1,215,455
Messages
6,124,935
Members
449,195
Latest member
Stevenciu

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