How to Filter One Topic using Dataview JS

Things I have tried

Here’s my code so far:

for (let group of dv.pages("#Clippings").where(p => p.Topics.includes("[[Streaming]]")).groupBy(p => p.type)) {
	dv.header(1, group.key);
	dv.table(["Clip", "Source"],
		group.rows
			.sort(k => k.file.name, 'desc')
			.map(k => [k.file.link, k.source]))
}

What I’m trying to do

I have a folder full of Studies and Reports that each have an inline field in the page that links out to topic hubs/pages. So, the frontmatter would look something like:

---
created: 2022-01-12T19:30:44 (UTC -05:00)
tags: [Clippings]
type: Study
source: https://www.competitionpolicyinternational.com/music-streaming-is-it-a-level-playing-field/
author: CPI -
---
**Topics**:: [[Streaming]], [[Music Charts]]

I am attempting to creat a dataview table that is grouped by the Clipping type, and then that filters down the clips by topic. My code worked up until grouping (so I was able to create a table of the clips separated by Type), but as soon as I added what I thought would be the filter (shown in the code above), the table that was rendered was just nothing. Not even an error was returned. Just nothing.

Can anyone point me in the right direction here?

Just coming back to say @mnvwvnm provided a solution over on Discord that worked!

You have to convert the links to a string to make it work:

p.Topics.toString().includes("Streaming")
1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.