Sort by a field value referenced by a link in Dataview

I have the following Dataview table that is successfully sorted by a value assigned to INDEX.

TABLE WITHOUT ID
file.link AS Projects,length(filter(file.tasks.completed, (t) => t = true)) AS Completed, length(file.tasks.text) as Total, "<progress value='" + (length(filter(file.tasks.completed, (t) => t = true)) / length(file.tasks.text)) * 100 + "' max='100'></progress>" AS Progress
FROM "PROJECTS"
SORT INDEX DESC

i would like to have the INDEX as link instead to text, but then sorting stops to work.

SORT [[INDEX]] DESC

What do you expect out of [[index]]? If that’s a link do you want to use the entire file content for sorting? What is the value of index?

No, the content of [[INDEX]] is irrelevant, I need to sort based on a value associated to it: [[INDEX]]::100

And how do you think you’ll get that value associated with a link? I don’t think you can use a link as an inline definition.

Here are some inline field definitions, and the corresponding values as seen by Dataview:

As can be seen index holds the value of heisann, but there is no values associated with [[index]]. And no fields holds the value of 5.

So when you state that doing the SORT INDEX DESC works, but SORT [[INDEX]] DESC doesn’t work. What doesn’t work about it? The first sort statement there refers to a INDEX variable within each of the corresponding files in FROM "PROJECTS".

I don’t know what value that is, but if it’s a field with the name of a note, possibly you’re looking for something like this?

```dataview
TABLE WITHOUT ID
  file.link as Projects,
  link(index) as Index,
  length(filter(file.tasks.completed, (t) => t = true)) AS Completed, 
  length(file.tasks.text) as Total,
  "<progress value='" + (length(filter(file.tasks.completed, (t) => t = true)) / length(file.tasks.text)) * 100 + "' max='100'></progress>" AS Progress
FROM "PROJECTS"
SORT INDEX DESC
```

This would sort by the note name, and add a link to that note in the second column using link().

If INDEX on the other hand just holds some random numeric (or not note-related ) sorting value, I’m truly at loss to what you want to achieve doing SORT [[INDEX]] DESC.

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