Have been looking for a solution to this for a while now. Thanks, thanks and thanks!
Hi All,
Just another very simple one I could do with some help on please!
I have some custom YAML fields:
ECLAM:
- Module_5
And would like to create an MOC from a Dataview query where it displays the file.names of all the notes which have the ECLAM Module_5 reference in their YAML, I have one test note with ECLAM: - Module_5
in the YAML and have the following query:
dataview
list where ECLAM ="Module_5"
sort file.name asc
But get zero results?! Could someone please help?
Thanks
Jim
We can do it with contains
.
```` dataview
list where contains(ECLAM, "Module_5")
sort file.name asc
````
If you were to find every file that has āECLAMā in it, it would simply be:
```` dataview
list where ECLAM
sort file.name asc
````
Tell me how it goes!
Perfect thank you @veradrawer - that works perfectly for my original questionā¦
I was wondering whether I can refine it further!! Can I add multiple āECLAMā sections within my YAML? For example:
---
ECLAM:
Module: 5
Keyword: imaging
---
- Is this possible?
- What would a query for ECLAM āModule 5ā look like if I did this?!
Thanks again everyone!!
Jim
As far as I know indented metadata is not supported in the obsidian yaml. The way Im doing it looks like:
---
ECLAM:
- 5
- imaging
---
and then
```` dataview
LIST
WHERE contains(ECLAM, "5")
SORT file.name asc
````
If you would want to have both:
```` dataview
LIST
WHERE
contains(ECLAM, "5") AND
contains(ECLAM, "imaging")
SORT file.name asc
````
You can change the AND for OR, and if you would want to get from Module 5 but not from imaging you would have to add an exclamation mark like !contains(ECLAM, "imaging"
.
On further note, I use two fields in every note: noteType
and noteClass
.
noteType
helps me group the type of note it is in the Luhmannās model of _permanent
, _literature
and _fleeting
; while noteClass
defines the actual content of the note, having such as _moc
, _quote
and so on.
So when I want to do a query, I start by defining the noteType
, and if needed, the noteClass
. A simple way of knowing things is by those things not done, so if Iām looking for fleeting notes, I simply search for notes that have neither the noteType
attribute (not propperly filled yet) or have it declared as _fleeting
.
Hope itās useful.
Hi, I am creating a work log for my projects using DataviewJS, yet I canāt figure out some sorting issue by myself. It would be great if you can give me some advice.
Here is my code. I customize it from @Wenās post.
for (let group of dv.pages('"Project"').where(p => "goal" in p && (p["brand"] == "Scutum")).groupBy(p => p["status"]).sort(p => p["status"], 'desc')) {
dv.header(4, group.key);
dv.table(["Name", "Goal", "Status"],
group.rows
.sort(k => k["category"], 'desc')
.map(k => [dv.func.link(k.file.path, k.file.name), k["goal"], k["status"]]))
}
I want to display all my project associated with āScutumā, which is the name of clientās brand. And I separate my work log with my notes by putting them in a folder called āProjectā. So I use .where() in the for loop to filter other projects in āProjectā folder. So far so good.
I record the day I finished that project in the field āstatusā and I tried to group them in an order that āIn Progressā comes first, and then dates. I used the .sort(p => p[āstatusā]) to achieve the outcome. However, it turns out to be reverse to what I want. So I tried .sort(p => p[āstatusā], ādescā), but the outcome didnāt change and I canāt figure out why.
Unfortunately, there is another small problem about the display of my field āstatusā. I recorded the date in YYYY-MM-DD, but it becomes āSeptember 10, 2021ā and the table gets very crowded. Is there a way to solve this problem?
@LinGaNinJa Regarding the sorting issue, maybe you can try replacing the quoted code with the following?
.sort(group => group.key, 'desc')
Regarding the date format, I remembered something like the following has been used in a post. Maybe the following can be put before your code:
var dateformat = "YYYY-MM-DD";
if (dv.current().dateformat) { dateformat = dv.current().dateformat; }
Hello, @Moonbase59
Is it possible to combine the outlinks
and inlinks
in one query?
This doesnāt workā¦but I donāt understand why it doesnāt.
```dataview
LIST
FROM ([[#]]) AND outgoing([[#]])
WHERE file.name != this.file.name
WHERE file.name !="zettelkasten"
SORT file.name ASC
```
Thanks
Angel
Sorry, @Moonbase59
I was not thinking straight!!
Fixed it. OR
not AND
:
```dataview
LIST
FROM ([[#]]) OR outgoing([[#]])
WHERE file.name != this.file.name
WHERE file.name !="zettelkasten"
SORT file.name ASC
```
Angel
Youāre amazing! Both solutions work perfectly! Iām really happy it works. Really appreciate your help.
Here is the final result. Looks so beautiful.
And here is the revised code.
for (let group of dv.pages('"Project"').where(p => "goal" in p && (p["brand"] == "Scutum")).groupBy(p => p["status"]).sort(group => group.key, 'desc')) {
dv.header(3, group.key);
dv.table(["Name", "Goal", "Status"],
group.rows
.sort(k => k["category"], 'desc')
.map(k => [dv.func.link(k.file.path, k.file.name), k["goal"], k["status"]]))
}
This is so insanely usefull that I canāt even express how cool and usefull I find it. Thank you!
I would add also this:
WHERE file.name != this.file.name
And this:
Projects due today or within a week from today
TABLE tags, deadline
FROM ""
WHERE deadline - date({{date:YYYY-MM-DD}}T23:59) <= dur(7 days)
SORT deadline ASC
I have YAML in the form of this
date:
array:
- detail1: āAā
- detail2: āB1ā
- detail1: āAā
- detail2: āB2ā
I am trying to have a table set up with the columns date, detail1, detail2 but I am not making any progress
The closest I can get is this query
table array.detail1, array.detail2
But there are annoying space consuming bullet points on my preview. I want a flat inventory like spreadsheet to be rendered
Like this?
A CSS snippet can suppress the bullets:
/* dataview lists */
.dataview-result-list-root-ul
{
padding: 0em !important;
margin: 0em !important;
list-style-type: none !important;
}
Angel
Can you please give full the dataview query? I have never used css before, I tried copy pasting that code in various intuitive places and couldnāt get desired results
Apologies. Only just seen your message.
The full dataview query is in the post above, localised to query files in my vaultās inbox.
The CSS isnāt part of the query; it is part of the styling used in the preview pane / output.
See the help directory for adding CSS snippets:
Angel
EDIT: the post below has a small sample CSS snippet and details about how to enable it. You could, perhaps, use it to see how CSS in Obsidian works. It is non-destructive and easily removed.
Hi Angel I got up to speed with css snippets today and implemented your example. The issue for me is that the bullet points arenāt the problem as much as the space they take up. Is it possible for the example table to only have two rows rather than the four they currently occupy?
UPDATE: My bad, I borked. I missed the fact that YAML demands the metadata section to be at the very top. However, I have two problems with dataview.
The minor one is that the following doesnāt work for me:
TASK
FROM "tasks"
WHERE (due = date(today)) AND !completed
As you might have guessed, Iām trying to show all non-completed tasks for Today. It returns zero results.
However, my major problem, that Iāve also mentioned below, is that dataview doesnāt work for me at-all on Android. Is it compatible only with the desktop version of Obsidian? If not, any ideas how to troubleshoot/fix the problem?
Feel free to ignore everything below. Iām leaving it here for anyone who wants to laugh at my absent-mindedness.
For some reason Iām not able to make the boolean logic work with dataview in my setup. Iād appreciate some help, since Iāve already spent hours trying to solve the problem and failing.
Iām trying a task management setup where Iāll keep all task-related notes in a folder (named ātasksā, in Obsidian Vaultās root). Then, I want to āpullā all tasks from there and have them listed in a single note, named ā010_Tasksā. My goal is to have this page, with all my tasks, easily accessible on both my PC and Android smartphone.
Each note with tasks might contain one or multiple tasks. Its structure goes like this:
# Title Like X-Project Tasks
%%
- - -
**Link:** [[Main_Project_Page]]
**Tags:** #maintag/subtag
**Time:** 15:30 Friday, 01-10-21
**Date:** 2021-10-02
**Notes:**
Anything goes here...
- - -
%%
- [ ] Task 1
- [ ] Task 2
- [ ] Maybe a 3rd one, too!
My first problemās on the PC. Iām trying to create some dataview rules that will pull data from all files in the same folder (ātasksā), but only present the tasks that match a particular tag. My latest failed attempt is this:
TASK
FROM "tasks"
WHERE Tags = "#maintag/subtag"
ā¦and, ideally, there should also be a ā!completedā somewhere, to hide completed tasks. I havenāt even reached that point yet. The output from the above shows nothing. Iāve tried enclosing the Tags = ā#maintag/subtagā in parentheses. Nothing. What gives?
Also, on mobile itās even worse: dataview seems to not be working at all. A plainā¦
TASK FROM "tasks" WHERE !completed
ā¦that does work on my desktop PC shows nothing on my smartphone.
Soā¦ Any ideas on what Iām doing wrong? Iām floored by what youāve all achieved, and I canāt even proceed to the first step!
Hi all,
I am new to Obsidian and dataview.
I am currently investigating using dataviewjs to extract the notes contains a certain string in a field.
For example, I have to extract all the notes with Name contains string āJohnā.
It might be Name :: John 123/ Name :: John abc/ Name :: Johnny
I am currently using
dv.list(dv.pages("").where(k => k.name.includes("John")))
But it prompted me the error:
Evaluation Error: TypeError: Cannot read property āincludesā of undefined at eval
May I have your help on this?
Thank You so much