How can I get the tags of the outlinks in a query?

What I’m trying to do

I have a folder with a note per Trip I made and on that note I put links to other notes like Countries (to link up the countries visited) or People (to link up people who were on the trip). These “Countries” and “People” are folders containing notes titled “Italy”, “france”, etc, and similar on the “People” folder.

Using dataview I list all the notes in the Trips folder and for each note I can get all the Outlinks. Now I wanted separete columns for all the Outlinks that are Countries and all outlinks that are People.

Things I have tried

I started by having a rule depending on the outlink path containing “Contries/“ but that doesn’t feel right so I thought on adding tags to pages saying “#country” and I wanted to filter the list of Outlinks to only contain Outlinks where the page has tag “#country” but Dataview doesn’t seem to be able to get the tags after FLATTEN’nd the outlinks.

Any suggestions on how to achieve this?

Found a solution!
I couldn’t find this behaviour documented, but it works:

filter(file.outlinks, (t) => (contains(t.file.tags, "#country"))) as Countries,

so my final query is something like:

```dataview
TABLE WITHOUT ID
file.link as "Trip Name",
file.tags as "Trip Tags",
minby(map(file.outlinks, (t) => date(t)), (k) => k) as "Trip Start Date",
maxby(map(file.outlinks, (t) => date(t)), (k) => k) as "Trip End Date",
filter(file.outlinks, (t) => (contains(t.file.tags, "#country"))) as Countries,
filter(file.outlinks, (t) => (contains(t.file.tags, "#people"))) as Who
FROM "Entities/Trips"

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