Dataview sorting issue - existing vs. not existing daily notes

I am new to Dataview and am I am having an issue with sorting notes by date. For each book note I list an attribute:

date_finished:: [[2023-07-19]]

I enter the date as a page, but I don’t create a daily note every day so some refer to non-existing notes. I have a table in a “Library” note where I am trying to sort by “date_finished”. It works except for the books where the date_finished actually points to an existing note.
I figured out from another post that the value of date_finished is the raw date when there is no file, but a path when the file exists, which messes up the sorting.

My simplified table code is:

TABLE author, medium, date_finished AS "date read", rating, "![20](" + cover + ")" as cover, meta(date_finished) as meta
FROM #book 
WHERE file.name!= "book template"
WHERE status!= "#book/status/readingnow"
SORT date_finished DESC

I tried looking in meta(date_finished) but there are no fields that just return the value.

How do I sort these notes just based on date, irrespective to whether or not the daily note exists?

Thanks!

I can’t replicate your results in local tests, but do you get any joy from:

SORT file.frontmatter.date_finished asc

EDIT:

If you want to query the metadata available in a particular note, you can use this code:

```dataview
LIST this
WHERE file.name = this.file.name
```

Thanks for replying and sorry for the slow response.

The first suggestion did not work, the order is now more scrambled than before.

Regarding the edit, I am not sure how to helps with an index note like that one I am having trouble with, but I am possibly missing something. Could you elaborate please?

You could try the hack of using:

SORT string(date_finished) DESC 

This I believe would return the display vakue, independent of whether the note exists or not.

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