Using your query as a starter, I see that within each group
(or month
) object, you can actually do the same GROUP BY
operation, like you did on pages
. But you need to do it on the group.rows
variable. So you were very close to actually solving it yourself.
Full script
```dataviewjs
let pages = dv.pages()
console.log('Pages', pages)
let months = pages.groupBy(p => p.month);
for (let month of months){
console.log('Month', month)
dv.header(2, `Month ${ month.key }`);
const weeks = month.rows.groupBy(g => g.week);
for (let week of weeks) {
console.log('Week', week)
dv.header(3, `Week ${ week.key }`)
dv.table(["file", "rows.month", "rows.week"],
week.rows.map(m => [m.file?.name, m.month, m.week]))
}
}
```
You don’t need the console.log()
statements, but if you expand those in the Developer Tools > Console, you’ll see that pages
is similar to month.rows
which also is similar to week.rows
. All being Proxy’s having a Target of DataArrayImpl
, which allows for GROUP BY
and all the other fun functions.
With my test setup, this script generates this output:
My <h2>
's are orange, and my <h3>
's are yellow, thanks to colorful headers of Minimal .