Dataview - Removing specific note from result

What I’m trying to do

I just want to remove “Tagnotes” from this result. It’s a hub note.
I keep all notes that aren’t attachments and templates on the same folder, and I don’t want to create a new folder just because of one stubborn note.

Things I have tried

The code I’m using:

table file.inlinks
where file.name = "tag ~ self-improvement & polymath"
where file.inlinks != "Tagnotes"

I tried changing the last line to where file.name != "Tagnotes" too. Didn’t work.

I also tried changing it to where file.path != "notes/Tagnotes" (idk if you use commas here or not, tried both, both didn’t work).

Honestly I’m out of ideas and giving up, just wanted to confirm here if it’s just a skill issue of my part or doing it is really impossible.

I added Dataview - to the topic title for clarity.

I am currently on a mobile phone, so I can copy & paste a line which works for me …

where !contains(file.path, "000 Index/Index") and !contains(file.path, "_testingFile")

… hope you can adapt to your needs.

Cheers, Marko :nerd_face:

Thanks for trying, but unfortunately it didn’t work too

Do you need to use inlinks? What about this for the last line:

and file.name != "Tagnotes"

Or at least try using and instead of 2nd where.

Cheers, Marko :nerd_face:

inlinks would be the right option, since it gives you the notes linking to the note you’re currently in (at least that was the point when I was using where file.name = this.file.name)

Even cutting the second where and trying the change you suggested, results are the same

I guess the problem is in how inlinks function, then. Would it be a bug? It doesn’t make sense for it to work this way

It seems like what you want to do is not to remove that note from the overall file set result list, but just the presentation of a given file. That is slightly different as to what I read when first read your request.

Secondly, you can’t compare a link with a text. That is you can’t check if a list of links, file.inlinks, contains just the file name (as a text), "Tagnotes". You need to compare links against a links.

My proposed solution for your query would be to do:

```dataview
table Links
where file.name = "tag ~ self-improvement & polymath"
FLATTEN list(filter(file.inlinks, (i) => i != link("Tagnotes"))) as Links
```

You see the WHERE clauses limits which files are presented as rows in your table, and having a WHERE clause to remove a file could be the correct option if you got a file list like “circle, square, triangle, Tagnotes”, where you clearly wouldn’t want the "Tagnotesto be included. Then you would do something likeWHERE file.name != “Tagnotes”`.

When you want it excluded in a row within your table, you need to use filter() or similar effects. I’ve separated out the actual filter operation into a FLATTEN line as I feel they’re easier to read. The explanation from outer to inner is as follows:

  • FLATTEN list( ... ) as Links - Take the array produced by ... and store that as a list into the intermediate variable Links
  • filter(file.inlinks, (i) => ... ) – Since file.inlinks is a list, and we only want the part of the list not being our file, we use filter to loop through the list, and for each of the links, i, we do our check
  • i != link("Tagnotes") – With i being a single link we can compare that against another link, which we create using the function link() and the filename
1 Like

Damn, I really couldn’t have written this on my own, I have used FLATTEN just once in my life, and didn’t even know filter() existed!

Huge thanks! It worked perfectly and the explanation was very clear.

2 Likes

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