Home > database >  Google Sheets: Need filter inside SortN
Google Sheets: Need filter inside SortN

Time:10-17

I'm trying to set up a sortn function with a filter inside, but for some reason this function isn't working:

=sortn(filter(AssessScores,AssessScoreStudent=C4,AssessOppor=A$1),1,0,TimestampScores,false)

I get an error: "Error SORTN has mismatched range sizes. Expected row count: 2. column count: 1. Actual row count: 300, column count: 1."

This works:

=sortn(filter(AssessScores,AssessScoreStudent=C4,AssessOppor=A$1),1,0)**

So something is going wrong when the sort column is added.

All of the named ranges are on the same workbook and sheet, the function is running in another sheet of the workbook.

Any ideas on how to fix this?

CodePudding user response:

If you give sort() or sortn() an array as the sort column, the array must be as tall as the data to be sorted. Use something like this:

=sortn( 
  filter(AssessScores, AssessScoreStudent = C4, AssessOppor = A$1), 
  1, 0, 
  filter(TimestampScores, AssessScoreStudent = C4, AssessOppor = A$1), 
  false 
)
  • Related