Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9782

Google Sheets: Sorting elements from a list when not all elements are present

$
0
0

Say I have some data that looks like this:

Column AColumn B
AprilMarch
JulyFebruary
FebruaryMarch
JanuaryAugust
JulyJanuary
AprilAugust
JulyOctober
April

Right now I've got

 column C  =unique(filter(A:A,A:A<>""))  column D  =unique(filter(B:B,B:B<>""))

which basically puts them in the order in which they appear for the first time in the original list, i.e.:

Column C - but in the wrong orderColumn D - but in the wrong order
AprilMarch
JulyFebruary
FebruaryAugust
JanuaryJanuary
October

But I want them to appear in Columns C and D like this, in correct sort order:

Column C - what I wantColumn D - what I want
JanuaryJanuary
FebruaryFebruary
AprilMarch
JulyAugust
October

If I need to create a named range containing all of the names of the months in my desired order in a different sheet, I'm happy to do that. Let's say I do so and call it MonthList.

When I try to do something like

 column C  =sort(unique(filter(A:A,A:A<>"")),MonthList,1) column D  =sort(unique(filter(B:B,B:B<>"")),MonthList,1)

then I get the following error for Column C (and a similar one for D, but with "expected row count" = 5).

SORT has mismatched range sizes. Expected row count: 4. column count: 1. Actual row count: 12, column count: 1.

So it seems like it couldn't sort the 4 or 5 unique items in the FILTERlist according to the order they appear in the named range with all possible items in the list.

How do I do it the right way?

Thanks


Viewing all articles
Browse latest Browse all 9782

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>