Dataview table that shows 2nd level links in a column

Hello…

If I do a “FROM” query where all files linked to a file (x) are shown; Let it be that one of these files is (y).

Can I then view a table, that shows in an another column all notes that are linked to files shown in the first column (i.e. files that are linked to (y))?

Something like the “relation” property in Notion.

Start query: all files linked to the file “[[x]]”

TABLE
FROM [[x]]

Now you want a second column with files linked to each file linked to “x”, i.e., you want file.inlinks to each file:

TABLE file.inlinks AS "linked to y"
FROM [[x]]
1 Like

Ah! Thanks alot. Can there be exemptions of file.inlinks listed in each column? i.e. file.inlinks except those with file name containing (z) in a column; and in another except those containing (t) etc…? or except those tagged with a certain tag?

Yes, that’s possible. But the solution depends on the complexity of the query.

Some previous points:

  • Don’t define a complex target without the basic learning of the plugin rules, syntax, etc. If you’re interested only in this specific query, later you can’t build another one or review this one if you a new update change the rules, if you change some metadata structure thinking that doesn’t change anything in the current query, etc.
  • Don’t get me wrong, because I don’t want to be paternalistic, but my help in Forum is directed to the learning curve in the plugin, not to give solutions prêt-a-porter without learn something.
  • I can give you this query example (to filter out file.inlinks with name equal to “zzz” - I said equal, not “contains”):
TABLE filter(file.inlinks, (i) => i.file.name != "zzz") AS "links to y except zzz"
FROM [[x]]

or with the function contains:

TABLE filter(file.inlinks, (i) => !contains(i.file.name, "z")) AS "links to y except files with z in file name"
FROM [[x]]
  • I ask: what you learn with these queries? the function filter()? contains()?
  • But if you want to repeat columns with filters, maybe you need to use another way (to simplify the code), using the command FLATTEN… but that is another level of complexity that seems you don’t be prepared to.

To conclude. I think you can use the examples above, but please take in consideration the long learning curve needed to understand and work with dataview (for example, I’m still a dumb in dataviewjs side :slight_smile: ).

1 Like

Okay. I know where you are aiming; as I can see now that my workflow needs to include certain tags in each column instead of excluding some file names. But I’ve not get it right yet; so I need to learn it.

I understood that filter() is used to filter in or out variables that equal i; and if I want i to be fuzzier that equaling some variable; I should use contain(); and using it needs me to change the syntax by adding parentheses before the i. + variable.

But; now as I am trying to use the same code to bring in input that includes a certain tag I seem unable to do it; I used this kind of syntax:

filter(file.inlinks, (i) => i.file.tag = "z") AS "links to y tagged z"
FROM [[x]]

I also tried i.tag instead of i.file.tag; But, it all seems not working.

:blush: Sorry for the inconvenience and ignorance

I have two ways:

  • give you the right code;
  • direct your to the solution.

I can make a mix of both (to not be named with bad adjectives :slight_smile: )…

Definitely you need to read the plugin documentation with some attention (docs) to learn two basic things: the right syntax for basic implicit data and the data structure.

For example:

  • you need to understand why in dataview (not in dataviewjs) we can use the link (in case the file.links) to index values through it (Expressions - Dataview);
  • you need to know that the implicit metadata for tags is file.tags, not file.tag;
  • to check the available metadata in a specific file, run this inline js query in that file (you need to enable inline js queries in settings > dataview):
`$=dv.span(dv.current())`
  • with the query above you’ll see the structure of the metadata in that file;
  • another important point is: you need to know what type of object you’re dealing - a string? a date? a list/array of values? a number?
  • for example, by default file.tags is an array (a list of values), even if yo have only one tag in the file;
  • because it’s an array, you can’t use “=” (for single values)… you need to use the function contains();
  • and contains(), as you can see in docs, isn’t only what you write above (works in different ways for strings, objects, for lists, etc.)

After all this maybe you can understand better filter(file.inlinks, (i) => contains(i.file.tags, "#tag")).

In a future question you need to show us that you’ve read the docs and tried simple queries…

1 Like

Thanks alot! This is a really good roadmap into understanding Dataview. Hopefully I won’t need help in next times.

Is there anyway to use this query to look for two tags, such as #tag OR #tag2?

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