Can you sort by two columns?

I want to sort a table by two levels, column A and column B. I can only see that you can sort by one column. Am I missing anything or are there any tricks?

You can create a template column that joins two columns together. Then sort by that template column. Just do some thorough testing to make sure it’s sorting correctly if your first column has varying lengths. For something like this, I like to separate both values in the template with a ‘-’ or ‘|’, so hopefully it sorts properly alphabetically.

5 Likes

thanks!

1 Like

I tried this method and it works but I ended up having to zero fill my numbers as it was sorting incorrectly. For example 100 would be sorted before 20 and 3. I used the following function in Google Sheets =ARRAYFORMULA(if(ISBLANK(D2),"",TEXT(D2,“0000000000”))). The challenge is that it the formula doesnt copy down when Glide creates a new row. Is there a way to put this formula in Glide Apps?

Try using D2:D instead of D2, I believe it will work.

However if you do not really need that data inside the Sheet, you can try Jeff’s method, which would work inside Glide.

1 Like

I have tried D2:D but the issue is that i get a #REF! Error.

As the error says, you have data in the rest of the column, so the arrayformula can’t fill the rest of the column. Delete the data in the column below the row that contains the formula.

2 Likes

That is perfect, I thought you had to copy the array formula down. I didn’t realize that you only have the formula at the top and the values automatically copy all the way down. This is AMAZING!

Thank you so much!

1 Like

One other thing I found out that I am others know but wanted to contribute. The CONCATENATE formula does not work the way I expected with the ARRAYFORMULA. Instead I used the CONCAT command and that did the trick. The only limitation is that CONCAT only combines two inputs.

=ARRAYFORMULA(CONCAT(B2:B,if(ISBLANK(X2:X),"",CONCAT(" → ",X2:X))))

You can read more about it here.

Hope it helps.

1 Like

I would use a template column inside Glide for this, again, if you don’t need to see that formula in Sheets.

1 Like