Can't get sorting to work in dataview

This look like a real simple task but for some reason I cannot get it to work. I have not used dataview often so it might be a beginner problem…

What I’m trying to do

I have some fields formatted like this:

#### project:: CCC
State:: 4
Upload:: V1

#### project:: AAA
State:: Done
Upload:: V5

I want to create a dataview table to show all these values sorted by project.

Things I have tried

This is my dataview:

TABLE without ID project as "Project", default(State, "TDB") as "Current state", default(Upload, "V0") as "Upload"
WHERE file = this.file
SORT project ASC

In another topic in this forum I read about the “default” values that can be assigned to a field when it’s empty. That also does not work.

No matter what I tried, the result always looks like this:

Any help would be greatly appreciated!

Hi HermannW,

The issue is that Dataview generally looks at your data at the page level, not the section level. So it doesn’t know that the first “State” is supposed to go with the first “Project”. All it sees is a single page that has four values for “Project”, four values for “State”, and so forth.

I recommend breaking up this data into four pages, each with its own State and Upload fields. If you did that, then you could query the pages with something like:

SELECT State, Upload

… and you would see a table that looks more like what you expect.

The WHERE State clause is to filter the list to show only pages that have a State field defined. You could also add a FROM to narrow the search to a particular directory or tag.

I hope this helps! Good luck.


Thanks Craig but that’s not a real option. I will have about 100 projects and currently I only need those three fields so that would make things too ocomplicated…


Edit: …but that gives me another idea that could work! :slight_smile:

You could also use lists within the same page, and get that separation of the projects, and ease of use in queries.

So maybe something like:

- [project:: X] 
  - [state:: 4]
  - [upload:: v0]]

Thanks holroy. I already found another solution that is not so much work. Had to dig a bit deeper into Obsidian functions.
Great program with way too many functions. :wink: