Dinamic ordering of rows - virtually ordering rows by clicking on up/down arrow within table view

Hello everyone,

I have the folowing question:

I am trying to make it possible to order some values dynamically.
I have a row with some names and their sequence (order) in a list, see below (f.e. in a competition where people are frequently having a certain particular position, that might change over time).

What I want to achieve is when I manually click on the up-arrow, the row should move up - when I manually click on the down-arrow the row should move down within the list. So the order no should change within the row i click on and within the row above/below.

I was thinking of having kind of virtual row with the related rows and take this way influence on the order within the related view, but do not know how to achieve it.
Does anybody has an idea what the expression should look like?

3X_2_9_29ce7eead636e0e63f4c2ea9949626b75ec3e3a5.png

Also would be great to be able to type in the new order no into a row, that the currect row with the same number gets a lower order no and all the rows beneath automatically sortet one row down (closing the gap of the order no, where the moved up row was taken away).

Thank you much for your help!

1 7 788
7 REPLIES 7

Hello,

Iโ€™m not sure whether there is a beautiful solution for it, but the first thing that comes to my mind is:

Letโ€™s imagine I have a table called โ€œProduction cycleโ€. In my case everything is ordered by SEQUENCE NO column.

  1. Create an action โ€œChange order: Sequence - 1โ€

  2. Create an action โ€œChange order: Sequence + 1โ€

  3. Create an action โ€œChange order: Set sequence of previous + 1โ€
    Referenced rows formula: SELECT(Production cycle[CYCLE ID], [SEQUENCE NO] = [_THISROW].[SEQUENCE NO]-1)

  4. Create an action โ€œChange order: Move upโ€
    This is the parent action that triggers the reordering process.

5,6,7,8. (The same logic is for the โ€œMove Downโ€ action)

You can use a method described here to trigger the action or:

  1. Go to Data -> Columns and a virtual column for your table called โ€œAction buttonsโ€
  2. Go to the โ€œChange order: Move upโ€ action and change the appearance to:

Hi Jackson,

thank you for your quick and very detailed reply. It is a working solution.

In my case there is a little more complicated point, I didnโ€™t mention:
Beside the order no I also have different categories (lets say, different competition).

3X_0_d_0d3c75123f7ea9e52f33ad3a9624ec88e052d364.png

It might happen, that I pull a person out of the category A into category B (what I would do manually by changing the row input.)
In this case, a person gets into another category and leaves a blank inbetween the previous and the following row.
Do you have an idea on that?

Or maybe there is a way to build it somehoq different that such gaps are closed?

Update


To hide arrows for the first and the last rows:

Step 11 For action โ€œChange order: Move Downโ€ Add behaviour formula:
COUNT(SELECT(Production cycle[SEQUENCE NO],[SEQUENCE NO]=[_THISROW].[SEQUENCE NO] + 1)) <> 0

If there are categories like in your case, then use this formula:
COUNT(SELECT(Production cycle[SEQUENCE NO],AND([SEQUENCE NO] = [_THISROW].[SEQUENCE NO] + 1, [Category] = [_THISROW].[Category]))) <> 0

Step 12 For action โ€œChange order: Move Upโ€ Add behaviour formula:
[SEQUENCE NO] > 0

Thank you very much. The solution works great.

I just have changed

Step 12 For action โ€œChange order: Move Upโ€ Add behaviour formula:
[SEQUENCE NO] > 0
to
[SEQUENCE NO] > 1.

Do you have an idea how to avoid gaps if I move โ€œmoveโ€ a row from one to another category?
Is it something that needs to be changed by a workflow that checks if there are any gaps of the accumulation. And if yes, it moves all the rows below the gap one up?

As well to avoid duplicated in the new category there is a automated initial value needed that is the last of the new table. Right?
How would you do that?

Thank you very much for the detailed description

Hmโ€ฆ I already deleted this functionality from my app, so I canโ€™t test it. But, I think we can do something like:

Create an action โ€œChange order: resetโ€
Using this action the sequence number will be set to an empty value


In the formula for SEQUENCE NUMBER just write empty brackets like this ""

Then another action โ€œChange order: move to the endโ€


MAX( SELECT( Production cycle[SEQUENCE NO], [category column] = [_THISROW].[category column] ) )+1

Then, we create a Workflow:

Update event: โ€œUPDATES_ONLYโ€
โ€œIf this is trueโ€ formula:
[_THISROW_BEFORE].[category column] <> [_THISROW_AFTER].[category column]

In โ€œDo thisโ€ block, we trigger the following actions:

  1. Change order: reset
  2. Change order: move to the end

In theory it should work.

Hi Jackson,

thank you very much for the detailed description. I appreciate it very much.
Currently it is not working properly.

I will be trying to find out why and let you know when its working.

In step โ„– 3 try changing the formula to
SELECT(Production cycle[CYCLE ID], AND([SEQUENCE NO] = [_THISROW].[SEQUENCE NO]-1, [Category] = [_THISROW].[Category]))

Top Labels in this Space