Dataview plugin snippet showcase

I think that limit is now removed in 0.3.13, mentioned in this issue

2 Likes

Ah indeed! I should have checked to update. Thank you!!! Now it is working perfect.

Iā€™m trying to build a list of notes grouped by the values of either a sub-tag or YAML value. Either route is fine if one is possible and the other is not.

I have front matter like this:

---
technology:
- Go
- PHP
---

And tags like:

#technology/Go 
#technology/PHP 
#technology/NodeJS 

And I am looking to make a table like this:

Go

Name Creation Date
File with Go tag 1 June 1, 2021
File with Go tag 2 May 26, 2021

PHP

Name Creation Date
File with PHP tag 1 June 1, 2021
File with PHP tag 2 May 26, 2021

This dataviewjs gets me close:

for (let group of dv.pages("#product").groupBy(p => p.product)) {
    dv.header(3, group.key);
    dv.table(["Name"],
        group.rows
            .sort(k => k.rating, 'desc')
            .map(k => [k.file.link]))
}

But I have two problems

  1. In my example, Iā€™m using a mix of tags (find pages with #product) and frontmatter (group by product). Iā€™d rather use either tags or frontmatter.
  2. Several of my notes have multiple product values. If my product array is [ā€œPencilā€, ā€œPenā€] Iā€™ll get a grouping of ā€œPencil, Penā€ not a section called ā€œPencilā€ and another called ā€œPenā€

Pasted image 20210608145413

Any suggestions for modifying my query?

Bit of a newb question here but how to I search for part of a filename?

EG my daily notes titles follow the format YYYY-MM-DD
And I want to find data from files from say June soā€¦

WHERE file.name = 2021-06

Iā€™ve tried various permutations (quotes, wildcards etc) but none of them seem to workā€¦

WHERE contains(file.name, ā€œ2021-06ā€)

2 Likes

@mnvwvnm Oh you star! I had tried that but put a space between ā€œcontainsā€ and the ā€œ(ā€ :smile:
So simple when you know how! - thank you!

3 Likes

Thanks. Your approach is cleaner and I would like to implement it if I knew how to make an inline field collect text from several paragraphs or list items. I have tried backslash, \, at the end of each paragraph or items in a list, but thatā€™s not it.

The option to add line breaks, <br>, within a single paragraph, although it solves the rendering of new lines both in Dataview and in Obsidian preview, compromises the readabilty of long lists in Obsidian Edit view.

Yeah, thatā€™s a good point, and I have not tried yet to experiment with that too much; my abstracts are just paragraphs. But youā€™re right that lists could be helpful.

Instead of fiddling with non-standard ā€œinlineā€ stuff you can as well put your multi-paragraph abstract into the YAML frontmatterā€”a practice Pandoc/LaTeX users have used since ever so many years.

Note: When using this format, each new paragraph in the abstract must start with a blank (which wonā€™t show in the output).

To better illustrate this, Iā€™ve switched on ā€œShow whitespaceā€ (so you see the blanks) and made screenshots of both edit and preview mode:


An Abstract in frontmatter YAML (edit mode)


The Abstract in the note, using Dataviewā€™s inline display

EDIT: Made a better example that shows using headings, emphasizing, strong, and highlighting.

6 Likes

Is it possible to export output data to csv? Without having to do anything too technical. Would be so handy to be able to export data from a tableā€¦ :smiley:

I am pretty sure you can just copy the table from Obsidian and paste it in a Spreadsheet app.

1 Like

@Rishi I thought this so unbelievable that I never tried it ā€¦ :rofl: And guess what? Dataview tables can really be ā€œjust copiedā€ from preview mode and pasted into LibreOffice Calc. Fantastic.

Not perfect though, but sometimes helpful.

Yeah, thinking of complex things often makes us forget that simpler things do work too!

The reason it works, I believe, has nothing to do with Dataview or Obsidian but just that the preview render is HTML and almost all spreadsheets can paste tables from webpages.

1 Like

Afternoon all - just a quick question from a relative noobie to Dataview that I was hoping someone might be able to help with.

Iā€™ve started fairly simple by creating an MOC for podcasts that I listen to. Just a simple:

```dataview
table author
from #podcasts 

That brings up the information nicely. However, in my head, clicking the name of the podcast would take me through to the page for it that already exists in my vault. Only it doesnā€™t, it creates a new (blank) page for me.

Is there a way, where I can re-direct the click through to the page that already exists rather than creating a new one?

Thanks alot for your help in advance!

@Melaniew @MortimerJazz I donā€™t wish to offend, but such questions should better be asked in the ā€œHelpā€ section, for others to find and respond to. This is the ā€œShowcaseā€.

@MortimerJazz It should do that.

2 Likes

The multi-paragraph text I now would like to be able to access is rich in links, and these are not updated when the target note is renamed nor can they be hoovered over.
However, I can think of some other uses for multi-paragraph values in yaml. Thanks for your clear reply and example.

No worries - sorry, I didnā€™t see a ā€œDataview helpā€ post so I posted here.

Iā€™ll have another look though!

2 Likes

You might actually want to just create a new post in the ā€œHelpā€ category. When you start a new topic, you get to pick the category from there. This also helps other people quickly find solutions if their problem is similar.

2 Likes

A quick question;

Does anyone else have problems with the sort when using [[yyyy-mm-dd]] as the date field?

I have a dataview table that sorts by date but it doesnā€™t sort accordinglyā€¦

```dataview
table project, date, attachment
from ""
where type = "meeting"
sort datum desc
limit 50
```

Then the dates sorted looks like this (again yyyy-mm-dd):

If I remove the brackets, removing the link to my daily template, then it sorts fine but dataview adds day to the date making 2021-06-09 look like ā€œwo 9 jun. 2021ā€. I donā€™t like that.

Does anyone else has this issue or perhaps even the solution?

2 Likes

You want to sort by ā€œdateā€, but your sort command refers to ā€œdatumā€ - maybe that is the cause of your problem?