Use a button to st

Is it possible to create a button that will sort a table? I created a button, set the formula to Tasks.Sort(true,Tasks.[Priority Sort Order]) but it gives me a “Unable to execute invalid action”. The same formula works if I just put it on the canvas.

1 Like

Right now I believe there is no way to directly control the sort functionality. What you could do, however, is use an If statement to control the order of the sort.

The short answer is to make a column called Sort Order with this formula

If([Sort By Priority], thisRow.Priority, thisRow.RowId())

Here’s an example:

For fun, I also wanted to see if I could alternate between different sorting behavior. This one switches from sorting by Name, to sorting by Date, to sorting by Priority, then back again.

Here’s the doc if you want to understand what it’s doing:

Neat hack and appreciate you putting that together.

The issue I have is that priority is label (High, Urgent, Blocker, etc), not a number. So I created a column called Priority Sort Order in the lookup table, which is also a column in my task table. I want to hide that column for the obvious reason. So when someone then sorts by another column like task name, it will then break that check box to sort by priority. The user won’t understand how to fix it.

I’d have to hook up checkboxes for every column they’d want to sort by and give explicit instructions to never sort using the sorting option in the table itself, and it’s still bound to break.

Either of these new features would solve this problem:

  1. Add the ability to sort a lookup column by the column order in the lookup table
  2. Allow a formula to change the sorting options of a table

You can sort a lookup column by column order in the lookup table. In the lookup table create a column called [Priority Value], its formula should be:


Then order as you wish.

Then in the table you want sorted create a lookup column called [Priority] where users can select the priority they want from the lookup table.

Then create a column called [Default Sort Column] whose formula is:

thisRow.Priority.[Priority Value]

Sort [Default Sort Column] in Ascending order.

In general, I tell me users not to manually sort if they see that a table is already sorting. But I agree with you, more robust formula support for sorting would be very useful. Especially if the sort functionality was itself a formula of some sort (or perhaps a type of filter)

1 Like