One of the functions of my app is to keep a list of people in a certain order (to determine whoโs turn it is to do a certain shift).
When someone has done the shift, they need to move down to the bottom of the list.
So basically, have a list of names, and a number behind their name from 1 to 25 (there are 25 people). I need something like an option to move people in this list (and make it save in the database). It can be a button that moves the top person to the bottom, or a drag/drop kind of thing if thatโs at all possible in the app. Does anyone have any suggestions on:
a) how to save the order of people in the database (I thought of using a column with the โnumberโ 1-25, but if thereโs a way to re-order the table rows, I could also use _RowNumber)
b) make it possible for app users to move rows around (at least it should be possible to move the top row to the bottom, making number 1 -> 25, 25 -> 24, 24 -> 23, โฆ and number 2 -> 1) .
Any help would be greatly appreciated!
This is actually a little more complicated than you would first think.
You could go your route and create a column to track the order, then create a series of actions that modify the numbers.
But you run into the problem of actions only modifying one record at a time.
For example: Letโs say you create the column to store the order, and everyone starts with their appropriate place in order 1 through 25. If we create an action to change the number to 25 (thus putting them at the bottom) whatโs really happening here is weโre changing a number to 25 - so now we have two people with the number 25, and everyone elseโs number hasnโt changed.
Sure, we could create a set of background updating actions that watches for changes in numbers, then re-assigns everyone in the list their new appropriate number. But this means every time you press the button to move someone down, youโve now got 25 edits that your app has to push to the cloud.
Methods like this work (Iโve done it several times before), but theyโre cumbersome and full of holes.
Allow me to suggest another method:
Create a column that tracks how many times someone has completed whatever task would move them to the bottom of the list. Then, you only need one action (to add one to the counter for that person) and you can sort your list by the count number then by rownumber (provided the records are in the correct order in the sheet).
For Example: Letโs say everyone starts at 0 (or blank) for their count; if we order them by count then by rownumber, weโll end up with all the 0โs at the top then ordered like in the sheet.
After the list has cycled through a few times (letโs say youโve completed the 4th and youโre working on the 5th cycle), you would have all the 4โs at the top and the 5โs at the bottom - and in each of those groups the people would be sorted according to their rownumber.
This should accomplish what youโre wanting but in a simpler manner. Lemme know if any of this didnโt make sense. (^_^)
Thank you so much for your suggestion. I think it might work, the only question is, what happens if I add a person to the list (i.e. a 26th person). Their counter would start on 0, which means -in your scenario after 4-5 cycles- for the next 5 shifts, they would remain on top of the list, until they have done the same amount of shifts as people who may have been working at my company for a couple of years. Do you understand what Iโm getting at?
So if a new employee joins the company, their counter would have to start at the highest number in the table, so that they get added โto the bottom of the listโ
Any suggestions on this?
Thanks again for your help.
Edit: Iโm now looking at the option of a hidden Date field, sort the people by the date of their last shift (ascending), therefore, people who most recently did a shift automatically get put on the bottom of the list. When adding new people, I just put the date of their last shift as the date they were added to the list (so that new people get added on the bottom). All I would have to do is make a button that sets the โDate of last shiftโ to TODAY when I click my โMove to bottomโ button. Iโll let you know how it goes.
try making an initial value formula like this:
max(Employee_Table[Count])
If you need to apply a condition, so you can exclude some records (say only include employees on a specific crew), you could try this:
max(select(Employee_Table[Count], [Crew] = [_thisrow].[Crew]))
User | Count |
---|---|
15 | |
10 | |
9 | |
7 | |
3 |