I have the following yaml and dataview code:
Status: ["Created", "Notified", "Complete"]
Days: [date(2022-01-03), "--", "--"]
Table without ID
Status AS "Status",
Days AS "Dates"
From "Notification 10554752.md"
Sort Days asc
When I preview the note I just get the headers
Status and Dates with the following response underneath from dataview:
Dataview: Query returned 0 results.
I can't seem to figure out what I'm doing wrong. I use the same dataview code on another file with different data points in the yaml and it displays the table just like I planned.
Any ideas what I'm doing wrong with this code?
### Things I have tried
<!-- THIS PART WON'T BE POSTED
We strongly recommend searching in the help docs (F1 in the app or online at https://help.obsidian.md) or this forum (https://forum.obsidian.md/search) before you post. It's always sweet to find answers so you don't have to spend time writing up the post!
If you still can't find it, please write what you have tried below (e.g. "I searched Mermaid in help docs but couldn't find anything") so that we have a better idea how to improve our help docs and this forum.
Please continue below this line: -->
### What I'm trying to do
<!-- THIS PART WON'T BE POSTED
Please describe what you're trying to accomplish so the community can better help you. Sometimes the solution you have in mind is not necessarily the best option, in which case knowing some background info can let others come up with creative solutions for your use case.
Please continue below this line. -->
First advice: before the way you need to write your dataview query, you need to know the logic of your metadata.
Status: ["Created", "Notified", "Complete"] means a list of multiples values, i.e., if you call this field you get:
Days: [date(2022-01-03), "--", "--"] the same thing (and you don’t need to add
date() to dataview recognise the format yyyy-mm-dd). Calling
Days you get:
This is to say: there’s no direct relation between values in “Status” and “Days”, i.e, “Notified” and “–” are just the second value in each field, not a direct relation. You can get them in the table in the same row but just because that is the initial order of your values inside your each field.
Now the dataview query.
- Are your file “Notification 10554752.md” in main folder, in vault root? If inside a folder you need to write all the path. For example
FROM "folder/subfolder/Notification 10554752.md"
- You can’t sort directly your field “Days”, because you got only one row (with multiple values). It’s possible to sort directly the values in field, but in that case you are confronted with the problem identified previously: with no relation between values in each field, if you sort “Days” the values in “Status” remain as before (don’t follow the new order in “Days”)
Thank you. What I’m trying to do is throw up a table in a file that has Status and Date as the column headers something like this:
You’re right. I forgot about the default dash, so I’ll just leave those blank until I add the dates.
Fixed issue 1.
Now it returns:
Status and Date as column headers, but there is just a dash under each.
Looks like it sees the file, but the data isn’t populating yet.
Found my issue. After putting it aside and coming back the next day with fresh eyes, the reason my code was producing dashes is because there was a Header above the YAML. Once I removed the header and made sure the YAML code was first, dataview could read the data the way I wanted.
Thank you for your help.
This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.