Dataview plugin snippet showcase

Hi @jmm, I think I chose a slightly different approach to this.
Instead of putting the abstract in its own section, I put it in an inline field under the title, like this:

abstract:: here goes the abstract/summary of the paper

The advantage is that since it’s an inline field, you can invoke it very easily from dataview; my table looks like

```dataview
table abstract as Abstract
from #project
sort author asc

The disadvantage is what’s above: seems like the default line length for the dataview table is capped at 500 characters. The good news is that that seems to be modifiable (per @Surjaa’s link to the discord thread; you can edit the plugin and increase this size, although will have to do it every time it updates. I haven’t experimented with this yet, so this is just based on the discord thread).

I like your approach too, but I’m really not very fluent in dataview yet so would have to experiment to see how transclusions work in it if they do.

3 Likes

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.

5 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?