Google-sheets – Google Sheet use filters to sort with Unique

google sheets

In google sheet, I have a data set A:

enter image description here

In another sheet I am creating a dynamic list using the UNIQUE formula:
enter image description here

However, when I use filters to sort the data, it gets all scattered leaving empty cells where there shouldn't be any:

enter image description here

Does anyone know a workaround to avoid this? Is it impossible to use filters AND Unique at the same time or is there another way to do this?

Best Answer

It's not possible to use the UI filters to filter the result of formulas like UNIQUE that return an array of values, instead you could use the built-in function SORT, i.e. =SORT(UNIQUE(A1:B6,1) among other alternatives (pivot table, Google Apps Script, copy-paste as values, then sort, etc.)