Using Data Commands on the "additional information" output in a dataview LIST query

What I’m trying to do

On page A I want to create a list using dataview that, on the first level, produces all other pages that contain links TO page A. Lets say page B is one of those pages. Then on the second level of the list I want to produce a list of outlinks that are in page B.

This I have been able to do successfully. The issue I am having is this:

I want to be able to use the data commands to manipulate the data in the secondary list. Specifically, I want to limit the secondary list to 5-10 links, and I would like to sort the secondary list by another parameter (like most recently edited, largest file size, etc).

I cant figure out how to apply any commands to that “additional information” using the LIST query.

I also don’t really like the look of using a TABLE query, so would love to figure this out using LIST.

Things I have tried

Below is what I am using currently, but it doesn’t filter the secondary list in any way.

list file.outlinks from [[]] and !outgoing([[]])
sort file.mtime DESC

I’m not sure if this is the cleanest solution to your request, but it is a way to sort your sublist at least. Not sure on how to limit the length of the sublist. One should possibly ask at github for truncate() to accept an array as input, and use that if or when its implemented.

The gist of the idea is that the only methods we’ve got for sorting are based upon alphanumeric sorting using sort() (and reverse()). To be able to sort on an arbitrary value, we therefore need to prepend it to the visible value using something like %% value %%. This doesn’t show up in the list, but it’s respected when doing the sort.

So if we wanted to sort on the file name, the following should do the trick:

LIST sublist
FROM [[]] AND !outgoing([[]])
FLATTEN list( sort( map( file.outlinks, (f) =>
  "%% " + + " %% " + ))) as sublist
SORT file.mtime DESC

This could be adapted to use whatever sortable value instead of, and output instead of and so on. The combination of FLATTEN + list( ... ) is used to ensure that the output is still a list, and not one row for each separate element.

1 Like

Thank you! That at least helps me with one of my questions. I appreciate it!

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