I’m using Obsidian to organize my podcast and without going into too many needless details, I have a note for video game characters to show what episodes exist with those characters broken down by various categories that are defined in the YAML frontmatter and Dataviewjs to make groups of tables for those categories.
One of those categories is “Also Has Games With” and I can get that list and grouping to populate correctly except for the part where I also have a group for the subject of the current note.
Let’s take a look at this example, which I pulled off of the Batman note.
Neat question!
Question: Is playablecharacters always a list or is it sometimes just a string?
Anyway, I think you can do the filtering you want just inside your for loop at the bottom: if (group.key === dv.current().file.name) continue;
right before making a header out of group.key continue basically skips the rest of the the for loop for the current value of group and goes on to the next one.
dv.header(2, "Also Has Games With:")
// get all published podcast episodes
let pages = dv.pages('"00 Podcast Episodes"').where(p => p.stage == "Published")
//let characters = "PlayableCharacters".where contains(PlayableCharacters, this.current().PlayableCharacters) commented out on purpose
// create group object
let groups = dv.pages(p.consoles).where(p => p.stage == "Published" && p.Type == "Regular Episode" && p.ComicPublisher != "NA").flatMap(page => dv.array(page.PlayableCharacters).map(t => Object.assign({}, page, {Guests: t })))
.where (p => p.stage == "Published" && p.PlayableCharacters)
.where (p => p.PlayableCharacters.includes(this.current().file.name))
.where (p => p.playablecharacters != this.current().file.name)
.groupBy(page => page.Guests);
for (let group of groups){
if (group.key === dv.current().file.name) continue;
dv.header(4, group.key);
dv.table(["Game", "EP Num"],
group.rows
.map(k => [k.file.link, k.epnum])
)
}
I added a character to the list called Acid because it seemed like a DC character name and comes alphabetically before Batman. Gives me this without that new line of code.