Get first item in list in dataview

I’ve already answered this question in your other post:

For those locating this through searching, the trick to find a given element is either through direct indexing, or through using some of the list functions, like max(), min() (or preferably maxby() or minby(), if you need to look into a list of links for example).

Here are some code examples:

  • file.inlinks[0] – Will give you the first link in the list
  • reverse(file.inlinks)[0] – Since we reversed the list, we now get the last element…
  • maxby(file.inlinks, (f) => f.file.day)) – Extract the latest date associated with any of the file.inlinks. Similar syntax can be used to pick your property of choice, e.g. f.myModificationDate

Regarding documentation you’ve got this forum when you learn how to search (which can be a little daunting), the main documentation site and also some of the resourced listed there (especially the example vault could be useful for some of the more advanced example queries).

1 Like