To start, related to the code itself, you don’t need
choice(typeof(DateWatched) = "array", DateWatched, list(DateWatched)) AS When
just
DateWatched AS When
.
But I guess you use that expression for “style” purposes (to see all values as a list… I’m using Minimal, I don’t have that problem, because there’s no “-” in dataview tables).
About the sorting thing, @holroy is right about the max()
or min()
. (We don’t know if, when multiple dates, you want to prioritize the last or the first.)
But the point is: you can’t do that directly with the links! Links aren’t dates:
- If you ask to
max()
ormin()
of links, you get an answer related with alphabetic order; - if you ask to sort a link, you get a sorting related with alphabetic order of the file path (link is a path)
So, you need to play with dates. To do that, if the “date” files exist, then you need to go through the link and target an implicit date value in that link. Using, for example, file.day
.
max(DateWatched.file.day)
not max(DateWatched)
.