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?
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!
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.
Create an action โChange order: Sequence - 1โ
Create an action โChange order: Sequence + 1โ
Create an action โChange order: Set sequence of previous + 1โ
Referenced rows formula: SELECT(Production cycle[CYCLE ID], [SEQUENCE NO] = [_THISROW].[SEQUENCE NO]-1)
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:
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).
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
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
""
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:
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]))
User | Count |
---|---|
43 | |
29 | |
24 | |
22 | |
13 |