obsidian-dataview
obsidian-dataview copied to clipboard
file.tags vs tags(frontmatter)
Describe the bug Using GROUP BY / FLATTEN in dataview query I'm able to obtain the expect result if work with "tags" via frontmatter (except the fact that the tag not be an 'active/clickable' element). That's not possible with "file.tags".
To Reproduce
- Query with "tags":
TABLE join(rows.file.link, ", ") AS Files
WHERE tags
FLATTEN tags
GROUP BY tags
Group | Files |
---|---|
tag1 | File A |
tag2 | File A, File B |
tag3 | File C |
tag4 | File A, File D |
tag5 | File D |
tag6 | File A, File C, File D |
The table is grouped as wanted - tag by tag -, although tags are not 'active' elements.
- Query with "file.tags"
TABLE join(rows.file.link, ", ") AS Files
FROM "Teste2"
WHERE tags
FLATTEN tags
GROUP BY tags
Group | Files |
---|---|
#tag1 #tag2 #tag4 #tag6 |
File A, File A, File A, File A |
#tag2 | File B |
#tag3 #tag6 |
File C, File C |
#tag4 #tag6 |
File D, File D |
The table isn't grouped as wanted - tag by tag -, although tags are now 'active' elements.
Expected behavior A mix of the two previous results: a table grouped as in case 1 with 'active' tags as in case 2.
Desktop (please complete the following information):
- OS: macOS BigSur
- Obsidian Version: v0.12.15
- Dataview Version: 0.4.8
The two queries are the same - I think you may have accidentally copy-pasted the same one twice.
The following query works for me to obtain both desired behaviors:
TABLE join(rows.file.link, ", ") AS Files
FLATTEN file.tags AS tag
GROUP BY tag
It looks like the GROUP BY
is grouping by lists instead of individual tags - do you have nested tag lists?
Thanks for your answer. And yes, you are right 🤦♂️... Sorry. The correct query was:
TABLE join(rows.file.link, ", ") AS Files
WHERE file.tags
FLATTEN file.tags
GROUP BY file.tags
I tried your query and works for me too. Thank you. About the nested tags, I have some in my "test" vault. But in target files/folder filtered in my query example, no.
Ah, the reason your second query is due to a bad Dataview interaction with how GROUP BY works - it makes a variable literally called "file.tags"
, which you have to obtain via row["file.tags"]
. I would use GROUP BY file.tags AS tag
to rename it to something usable.
This mostly appears to be a UX problem with GROUP BY doing something stupid with variables with dots in them. I may be able to fix the behavior.
Once again, thank you for the clarification and for all availability.
Hi mnvwvnm, is this fixed?
Are you moving under the rug, on the dust of history? 😄
I guess it's not fixed... i.e., the behavior remains the same. But now I rename every flatten
and group by
actions and it becomes a non-issue.
I see, let's keep this open then.
Looks like there's nothing to do here since we've documented the row
syntax. Closing.