What I would like is to have some extra information in the file links that group the results.
E.g., the page may (or may not) have the following metadata fields: project-id, project-area, project-status etc.
And instead of just “@shannon-1949-mathematical-theory”, I would like the underlying generated markdown to look something like:
The GROUP BY expressions allow you to do just that, add an expression, so you should be able to do something like:
GROUP BY project-area + " " + project-id + " " + file.link
Or if it’s not a given that the field you want to include is always set, you could try some variant like: choice(project-area, project-area + " ", ""). Where if it’s set it include the value and a space, and if not set, it’ll just do an empty string.
If you want to sort on the same expression, you could either just add SORT key at the end, or use FLATTEN to store the result for later retrieval in other parts of the query, like in the following:
FLATTEN project-area + " " + project-id + " " + file.link as myThingy
GROUP BY myThingy
This latter version could potentially also allow for the myThingy to be used in WHERE clauses and so on.
I suppose I use dv.query() and pass in the query string if I want to do this in dataviewjs? I see dv.taskList() takes true/false to determine whether it should group by file, but not a way to support custom keys/fields as the DQL GROUP BY.
One weirdness I noticed is that with the above approach, dataview picks up tags when given in the yaml but not in the body. So, for e.g., the logic I use above will pick up “foo” (as a tag, without the “#”) but not “#bar”.
If you extend your tag example with the following:
Just `tags`: `$= dv.current().tags `
Using `file.tags`: `$= dv.current().file.tags `
You’ll hopefully see that the latter does include both, but the former only lists the frontmatter variant. Whether this is intentionally, or to be considered a bug it for someone else to comment upon. I’ve not seen it referenced elsewhere that there should this distinction, so I’m likely to call this a bug, and something which ought to be mentioned on the github page of Dataview.