One thing I have noticed recently is that Enum columns, when used for Grouping, sort based on the ORDER of the Enum values listed in the column config. If you want Ascending, it’s the order they are listed in the Enum Column config. Descending is the reverse order. You can re-organize the Grouping order by moving the Enum values in the list.
I wonder if this can be used with Enum values that are pulled in by an expression? In other words, make the column you are using to Group by an Enum type column. Then assign, into the Valid_If, an expression that grabs the values from all rows and sorted using an ORDERBY() function. It sould be a complex function. I’ll try testing it.
I was also initially inclined to use the enum approach. Realized that the enum will need to have a moving set of valid values and display values because the dates of today, tomorrow and the day after tomorrow will change on a daily basis. So the enum may need possibly a daily scheduled bot etc.
Anyway, this could be possibly done , (I mean adding moving values ) and I could be possibly missing something obvious that is easier. I am sure @WillowMobileSys will come up with some innovative approach. Will be keen to see his solution.
I put my thoughts above to a test and it did NOT work.
While I can sort the Enum list dropdown in the expected order, it appears that AppSheet does not using this ordering for Grouping. It reverts to text based sorting. See images below.
There are a couple of things you still can do:
The only way I know, without additional work, to get them sorted in your desired order is to make the text sort in that order. That typically requires prefixing with numbers 1,2,3,4,5, etc. It’s not very user-friendly and since your ordering is DYNAMIC, you have to update EVERY row daily.
If you are willing to compromise a bit. I do have another solution described below
This would result in a view that looks like the one below. The “Today” and “Tomorrow” labels would stick to the top of the list - which might be good if these are the most important sets of rows.
The remainder of the rows would then be sorted by their date order.
Two things are required to make this work:
You need to add ALL 366 dates (including 29 Feb) as Enum values to the column used for Grouping. Cumbersome but You only need to do so one time.
You would still need a daily process to flip the Group values from its date to Today/Tomorrow and also back from the Today/Tomorrow to the date value. But the set of rows needing processed would be filtered down to just those dates - so a lot fewer to process. You could use a Virtual Column but I would recommend that ONLY if you are filtering rows down to smaller set that are actually displayed to the users. Otherwise, these “labels” would be recomputed on every Sync for every row and as the table grows so does the processing time to recompute all the labels - even though most don’t need touched at all.
So suggested a summary view based solution. The VC will keep creating the dates expressions as the days shift and then linktofilteredview selects the desired records.
Of course, it can be personal choice of what one thinks as compact approach.
Hi @TeeSee1 ,
May be I am missing some point. However if a prefix in the form of [1] for previous dates, [2] for Today , [3] for Tomorrow and [4] for later dates is to be applied, then I believe the following simpler expression for the VC will work. I mean this expression does not have the SELECT() statement in the VC. The VC computes based on the current row’s date and adds the necessary prefixes and formatting of the date in D MMM format.
I now understand the thought behind your solution - grouping by each individual date with special emphasis by way of additional prefix on the immediately following dates dates of today, tomorrow etc.