This one should be simple yet I’m unable to do that. Say I have note A and B having
key:: value1, C and D having
key:: value2. Is there a way to have a list that group the key like this?
group by key
but it only returns a list of values:
Maybe this could be a workaround:
TABLE rows.file.name AS Notes FROM #mytag
GROUP BY mykey
You can put one value to display after the word LIST so you could try the idea from @I-d-as as a list also (just remove the “AS Notes”). Note: I haven’t tested this, apologies if it does not work.
That worked for me. Thanks!
Edit: Looks like this:
what does the
rows do? I try:
list rows (DQL)
but they doesn’t yield anything special. However if I use
group by key
then it lists the fields in an organized structure. I cannot find any docs about this.
In the dataview GROUP BY documentation, it says:
Group all results on a field. Yields one row per unique field value, which has 2 properties: one corresponding to the field being grouped on, and a
rows array field which contains all of the pages that matched.
GROUP BY field
GROUP BY (computed_field) AS name
In order to make working with the
rows array easier, Dataview supports field “swizzling”. If you want the field
test from every object in the
rows array, then
rows.test will automatically fetch the
test field from every object in
rows, yielding a new array. You can then apply aggregation operators like
sum() over the resulting array.
Yeah I read it several times but I have to admit that I don’t understand much. Can you explain it clearer?
In this video at around 49:20 GROUP BY then ROWS are discussed. I haven’t watched this entire video in a while, so there is likely some information that is dated. But it should do the trick.
I hope this helps.
rows is an object. Where is it stored? What is the difference between it and
If you are thinking about objects, you might benefit from looking at the dataviewjs documentation or the source code for dataview itself (TypeScript). dataviewjs has a concept of “pages”. Each of your Obsidian notes is a “page” as is the specific page
this. Pages have fields including the implicit
file field as well as all the explicit dataview fields you have written into your frontmatter or inline. When you say something like
LIST FROM "folder", you are saying:
find all the pages in “folder” and list their links for me
LIST FROM "folder" WHERE mykey is:
find all the pages in “folder” that have a non-null field myKey and list their links for me
Value1 in your case) and then ANOTHER DataArray
rows which now contains the “pages” for each item in the group. Before GROUPBY: DataArray with pages, 1 per row, After GROUPBY: DataArray containing some number of groups and a
rows DataArray for each group with the pages corresponding to that group.
In other words
rows does not exist without a previous GROUP BY.
rows is a DataArray of “pages”.
this is a “page”. “Pages” contain the implicit field
file and whatever explicit DV fields you have written into that note.
I see. Should this be added somewhere in the doc for advanced users?
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.