Dataview - How to create a list of items with descriptions?

Hi, I want to create a list of items with descriptions, like this:

shells

The following code works nicely:

LIST WITHOUT ID link(file.path) + " - " + desc
FROM [[#]]
SORT file.name ASC

However, it fails if the desc property is not defined.

How can I account for missing properties? Ideally, I would like to hide the dash in such cases as well!

Thank you for your suggestions.

How does it fail? Do you call it a fail when it display an extra dash?

You could try:

```dataview 
LIST WITHOUT ID file.link + choice(desc, " - " + desc, "")
FROM [[]]
SORT file.name 
```
2 Likes

Try this one:

LIST WITHOUT ID link(file.path) + choice(desc, " - " + desc, "")
FROM [[#]]
SORT file.name ASC

To address the issue of missing properties in your Dataview query, you can use the default link function or a choice link to handle cases where the desc property is not defined.

With default would look like this:

LIST WITHOUT ID link(file.path) + " - " + default(desc, "")
FROM [[#]]
SORT file.name ASC

But not sure if you can hide " - " :thinking:

I am currently not behind my computer, so not able to test it :frowning_face:

Cheers, Marko :nerd_face:

1 Like

My bad. When I tried it, I got an error. But now it works (sans the extra dash), so I must have made a mistake elsewhere.

Guys, thank you for pointing me to the choice() function. That did the trick!