Filtering a list in DataviewJS

What I’m trying to do

I am trying to write a query using dataviewjs or inline queries. (I apologize if I get the terminology wrong, I’m still figuring it out)

I’m using dashboard++ and I’m able to use dataview to filter a list that gives me the correct results, but it adds a side to side scroll under the list which I’m trying to remove, but couldn’t find anything about it.

image
image

I noticed that if it’s written like dataviewjs or inline queries then the side to side scroll disappears.

For example:


image

However, I can’t figure out how to filter out content when using dataviewjs. For example, in my properties, I have ‘type: meeting’ or ‘tags: - agenda’ as seen in the first image, but no clue how to filter the dataviewjs to filter the same way.

So, my question I suppose has two parts. Is there way to get dataview to not have a scroll at the bottom?

or

Is there a way to add a filter properties when using dataviewjs?

Things I have tried

I’ve tried a searching it up to write a filter, for example, where(t => t.file.type = “meetings”) or something similar, but it doesn’t actually do anything for me and the results are the same with or without it.

Example:
image

I’ve tried using the tag as the source, but then it pulls any page with the #tag even if it’s not in the properties.

Thanks for any advice!

You’re very close, you just need to change your = into a ===.

= means “Set t.file.type to be the value of ‘meeting’”

=== means “If t.file.type is equal to ‘meeting’”

With t.tags, since it’s an array you’ll need to use:

where(t => t.tags.includes('some-tag'))

1 Like

Thanks for your help!

I’ve included the suggested expressions, but it’s pulling no results.

Editing mode:

Reading mode:
image

Also, perhaps I’m typing the tag line wrong? I’ve tried a few variations for trial and error, but it says there’s issues with includes or contains

Editing mode:

Reading mode:

Thanks, I’ve switched it, but there seems to be an error. It says "Cannot read properties of undefined (reading ‘includes’)

That means you are selecting pages which don’t include the type property at all, so Dataview is unable to filter for types which include meetings, since type doesn’t exist.

Use ?. to say "don’t continue the command if this thing doesn’t exist.

And also I think it would be smart to take a Javascript 101 course, because this isn’t anything to do with Dataview, this is just plain Javascript which you need to read up on.

```dataviewjs
dv.list(dv.pages('').where(t=>t?.file?.type?.includes('meeting')))
```

Thanks for your patience and advice, I’ll definitely take your advice regarding the JavaScript 101.

So, I’ve tried what you mentioned with ?.

image

I’m guessing that means ‘type’ is the one that doesn’t exist?

image

This is at the top of all my notes though. So, maybe I’m misunderstanding something.

It would have been easier from the start knowing your frontmatter format:

```dataviewjs
dv.list(dv.pages().where(t => t.type === 'meeting').file.link)
```

Thank you! I didn’t realize the frontmatter format was different, I just used whatever was in properties.

Much appreciated and I’ll definitely look into a beginner’s JavaScript course or video!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.