Dataview plugin snippet showcase

Hello ,

I had a lot of difficulties to find how to sum data from daily note into weekly and monthly consolidations. Here is what I’ve found

Here is the data per day I want to sum:

The data is read from the YAML front matter

---
sport:
  freeletics: 15
---

To sum per week:

TABLE
	sum(default(rows.sport.kettlebell,0)) AS "Kettlebell",
	sum(default(rows.sport.freelitics,0)) AS "Freelitics",
	sum(default(rows.sport.pushups,0)) AS "Pushups",
	sum(default(rows.sport.abs,0)) AS "Abs"
FROM "daily"
GROUP BY file.day.month + "-" + file.day.week AS pipo

Result:

To sum per month:

TABLE
	sum(default(rows.sport.kettlebell,0)) AS "Kettlebell",
    sum(default(rows.sport.freelitics,0)) AS "Freelitics",
    sum(default(rows.sport.pushups,0)) AS "Pushups",
    sum(default(rows.sport.abs,0)) AS "Abs"
FROM "daily"
GROUP BY file.day.month AS pipo

Result:

Hope it helps someone

6 Likes

Very nice! Unfortunately, I couldn’t make it work.


Am I doing something wrong?

P.S.: The frontmatter

---
sport:
  freeletics: 15
---

didn’t work.

What is the grouping supposed to indicate? Week numbers?

Hi All,

I’ve tried looking, but can’t find the answer to this simple question.

I would like a list of the notes created between a date range (for weekly/monthly reviews) and I can’t work it out!

So far I have:

table file.cday
where file.cday > (date(2021-07-01))
sort file.cday asc

Which displays all of the notes in a table since 1st Jul-21, but I need to put an end date on it (31st Jul-21)!

Any help?

Jim

Hello, Jim.

Does this work?

TABLE file.cday AS "Date Created"
WHERE file.cday >=date(2021-07-01)
AND file.cday <=date(2021-07-31)
SORT file.cday asc

Angel

3 Likes

Greatings Dataview wizards,

I’m trying to implement task management as showcased here. However I’m not able to make progress computation work.

How should the tasks object be populated?

Hello there, I’m very new to this forum but have been reading some on this topic.
I use Obsidian mainly for Bible study, and have started to put Bible verses as seperate notes in my Vault. Their title is like this: “Mt. 5.3”
I thought the dataview plugin would be nice to query for a list or a table of Bible verses in a specific book (grouped by chapter if that would be possible).
Now when trying to write a query to do this, dataview doesn’t seem to recognize the chapter number very well and it doesn’t sort correctly (sorts as 1, 10, 101, 11, 2, 21, …).

This is my current code snippet:

LIST FROM "Bijbelverzen"
WHERE contains(file.name, "Ps.")
SORT file.name ASC

And personally, I wouldn’t have any idea on how to group by chapter. The verses don’t contain any YAML frontmatter for the reason of simplicity when taking notes.

Would anyone have an idea of how to solve this and how to write a query that correctly searches for and sorts verses of a specific book?

See image for an example query result:

Thank you very much!
Niels

Absolutely perfect @anon12638239 - thank you!!

A pleasure. Good to hear it works as you need it to.

Angel

Hi nielsdep,

One way to ensure that the files sort correctly would be to name the files giving chapters and verses leading zeros. Your file names might look like:

  • Ps. 016.03
  • Ps. 018.08,9
  • Ps. 018.25
  • Ps. 139.01
  • Ps. 139.14

Naming them this way will allow Dataview to correctly order the names the way you expect.

Hope this is helpful.

Craig

1 Like

EDIT:

“econtains” is the wrong operator. This query works:

```dataview
LIST
WHERE contains(company,"Disney")
```

====================

I’ve seen several examples on here of using the WHERE clause in interesting ways but none seem to address my use case. I’d like to use a WHERE LIKE style phrase. I understand that the closest to a “LIKE” operator is the “contains” clause in Dataview.

Use Case follows.

I use meta fields to create a lite CRM in Obsidian.

I have “company” notes spread across multiple folders in Obsidian. When I create a note for a person I will add a YAML field for “company” and use internal linking to insert the company name property.

I have a field for “company” that looks like this for each “person” note:

---
company: [[Notes/Disney]]
date: 2021-09-03
tags: contact
---

I’d like to use Dataview to display all notes with the company “Disney” meta field. I don’t want to worry about the folder that the “Disney” note is in. I’ve tried variations of this Dataview query but they all fail:

```dataview
LIST
WHERE econtains(company,"Disney")
```

I get zero result for the above query

I‘m not an expert, but you could try this:

---
company: "[[Notes/Disney]]"
date: 2021-09-03
tags: contact
---

Hello,
Yes weeks numbers are per month and not yearly week number so I concatenate month and week number to get unique weeks groups.
The frontmatter needs to use 2 spaces to indent. Is it working with 2 spaces?

1 Like

Is it possible to use Dataview to get all pharagraphs (in all documents) that contains a tag? Example of paragraphs I have in several notes:

Note 1:

  • Today I had a meeting with #John
  • I discussed an interesting topic with #Lizz
  • I bought a house

Note 2:

  • #Tom and #John are now doing a new project together.
  • #Lizz wants a raise

And so on…

Now, I want to add a note called [[John]] to my vault, that fetches all pharagraphs (from all notes) with the tag #John in them. In other words: The output should be all sentences/paragraphs concerning #John.

Is this even possible with Dataview? I have tried this code, but obviously it doesn´t work:

LIST FROM #John

The above lists all the notes where #john exists, but I want the surrounding text. Is it possible?

2 Likes

Hi, I need some help for something that I can’t figure out by myself: I have a very metadata heavy organizational system that benefits from having maps of content using breadcrumbs.


Every folder has a unique _folderName file that works as a content Index.

The problem relies that I’m trying to make a list of every value the yaml is storing; like essay or guide are docype attributes.

imagen
The YAML looks like this (suggestions for improvements welcome).

I need help making Dataview display a list of every existing value under a certain attribute, this is the best I managed until now:

 ### List of document types

 ``` dataview
 list
 where doctype
 group by doctype
 ```

imagen
The output is a grouped list of every existing combination of values under docType.

I’m trying to achieve it giving me something like this:

imagen
A mockup of the desired outcome.

What could be done?

1 Like

Now it works, thanks. I wonder if there is a way to dataview not only reps but also weights. E.g. kettlebell: 2 reps, 10 kg.

I have not seen a way to do that directly in Dataview but you may consider the Obsidian query language. For example, this query may do what you want:

```query
path:"Notes/" block: (#John)
```

This will find all blocks that have the string “#John” in a folder named “Notes”.

This will only work with tags that use an octothorp. If the tag is set in the YAML without an octothorp then this query will skip those because it is an exact string match.

5 Likes

Brilliant, @macdrifter :slight_smile: This solved it for me. Thanks!

How to display an ordered number in front of each bar,Thanks!

Hello, you can add any hierarchy:

sport:
  kettlebell:
    reps: 2
    weight: 10

Then

	sum(default(rows.sport.kettlebell.reps,0)) AS "Kettlebell reps",
3 Likes

I managed to solve it.

```` dataview
TABLE
	without id
	join(doctype, "") as docType,
	rows.file.link as File
FROM "Notes/Zettle/References"
WHERE
	doctype
	AND file.name != this.file.name
flatten doctype
group by doctype
SORT doctype asc
````

This produces a table that lists every stored value in docType.

Bonus: As a happy accident I discovered that using without id in the first line after declaring a table hides the first column, allowing for more customization!

13 Likes