Essentially I want to make a table of notes sorted vertically by post date and horizontally by channel. I’ve had an immense amount of trouble with this, but I feel like I’m probably missing something obvious. As best I can tell dataview should be able to do this easily.
Things I have tried
The best I’ve been able to do is reference one channel at a time.
LIST rows.file.link FROM #post
WHERE channel = "SLS"
GROUP BY postdate
I was considering doing this and using a columns plugin to achieve a similar result, but that just seems really inelegant and messy.
My clumsy way of creating a table below. Not what you want. Hope someone else can provide an elegant solution for you.
---
date: 2023-06-01
SLSYT: Pride Tribute
SLSI: post pride tribute 1
SLIL: post sli 1
SLSTT: post pride tribute 1
---
```dataview
TABLE WITHOUT ID
date, SLSYT, SLSI, SLIL, SLSTT
WHERE file.name = this.file.name
```
The trick to this kind of output is that to find something common to group by, aka postdate, and then for each of the columns select the relevant entries in the rows array.
This results in a query like the following:
```dataview
TABLE
join(filter(rows, (r) => r.channel = "SLSYT").file.link, ", ") as "SLSYT",
join(filter(rows, (r) => r.channel = "SLSI").file.link, ", ") as "SLSI",
join(filter(rows, (r) => r.channel = "SLII").file.link, ", ") as "SLII",
join(filter(rows, (r) => r.channel = "SLSTT").file.link, ", ") as "SLSTT"
WHERE channel AND postdate
GROUP BY postdate
```
From a similar test run in my test vault I got this output:
Thanks for writing this up! I just tried it out and it works perfectly!
I had been diving into the dataviewjs to try and figure this out. This is so much simpler and makes so much since! There are actually many tables I’d like to make of this style, so knowing this pattern is extremely helpful.
Thank you again for the help with that! It has worked out perfectly. If you have time, I’d love if you could help me tweak it just a little bit.
I’ve run into a small issue where I’d like some posts to appear in more then one column on the table. I’ve tried sever different syntax variants of contains instead of r.channel = “lorem” to no avail. The YAML it would be referencing would be:
channel: [SLSTT, SLSIG] as well as the usual channel: SLSIG etc. Basically some posts will be cross posted to other channels and I wanted to have it update to reflect that by adding additional values to the channel key in the YAML instead of having to make a whole new note.
Everything I’ve tried keeps spitting errors. If you have the time I’d love to get your thoughts. Also, if it’s a wildly difficult thing to do, I can live without that feature.